Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function compressed = RLE(img)
- [rows, columns, pages] = size(img);
- % Use 'help cell' para ver mais sobre cell arrays.
- compressed = cell(rows, 1);
- for i = 1 : rows
- new_row = [];
- count = 0;
- current_color = mat2vec(img(i, 1, :));
- for j = 1 : columns
- aux_color = mat2vec(img(i, j, :));
- if aux_color ~= current_color
- new_row = [new_row, count, current_color];
- count = 1;
- current_color = aux_color;
- else
- count = count + 1;
- end
- end
- new_row = [new_row, count, current_color];
- compressed{i} = new_row;
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement