0

Hello i have a matrix whose rows and columns are multiple of 8 let's say 256x160 and i need to have as output all the possible submatrix of 8x8 elements. Fore few elements i can write

  bloc = 8;
  imm = imread('cameraman.tif');
  [rows, columns, dimension] = size(imm);  % dimension if the image is RGB
  nr = rows/bloc;  % numeber of blocks of rows
  nc = columns/bloc;  % number of blocks of columns
  cell_row = repmat(bloc,1,nr);
  cell_columns = repmat(bloc,1,nc);
  N = mat2cell(imm, [cell_row,[cell_columns]);

I think that now it works quite good but if there is a better way just tell me thanks

Andy
  • 23
  • 7
  • 1
    Read the documentation for [`mat2cell`](http://www.mathworks.com/help/matlab/ref/mat2cell.html). If you still have problems please update your question with "what you already try and didn't work". Good luck! – Dev-iL Mar 13 '16 at 17:09
  • [This](http://stackoverflow.com/questions/20336288/for-loop-to-split-matrix-to-equal-sized-sub-matrices) may be of help – Luis Mendo Mar 13 '16 at 17:51

0 Answers0