SHARE
TWEET

Untitled

a guest Oct 9th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function compressed = RLE(img)
  2.  
  3. [rows, columns, pages] = size(img);
  4. % Use 'help cell' para ver mais sobre cell arrays.
  5. compressed = cell(rows, 1);
  6.  
  7. for i = 1 : rows
  8.     new_row = [];
  9.     count = 0;
  10.     current_color = mat2vec(img(i, 1, :));
  11.    
  12.     for j = 1 : columns
  13.         aux_color = mat2vec(img(i, j, :));
  14.        
  15.         if aux_color ~= current_color
  16.             new_row = [new_row, count, current_color];
  17.             count = 1;
  18.             current_color = aux_color;
  19.         else
  20.             count = count + 1;
  21.         end
  22.     end
  23.  
  24.     new_row = [new_row, count, current_color];
  25.    
  26.     compressed{i} = new_row;
  27. end
  28.  
  29. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top