I want to split any matrix into equal parts of sub matrices. I used mat2cell to do that. But it makes most of the sub matrices as desired size but the some parts are not equal. For example: I have a matrix of size 973*973. I want to divide equally into 216*216 sub matrices. When I apply mat2cell, It makes a 6*6 sub matrices. In which first 5*5 are 216*216 sub matrices. But the blocks in last row and columns are not 216*216. They are random sizes. Which is not desired.I want every sub matrices will have equal number of rows and column. Every blocks will be 216*216 size or what specified by the user.
I=imread(file);
[rows columns numberOfColorBands] = size(I);
blockSizeR = 256; % Rows in desired block which can be anynumber.
blockSizeC = 256; % Columns in desired block which can be anynumber.
wholeBlockRows = floor(rows / blockSizeR);
blockVectorR = [blockSizeR * ones(1, wholeBlockRows), rem(rows, blockSizeR)];
% Figure out the size of each block in columns.
wholeBlockCols = floor(columns / blockSizeC);
blockVectorC = [blockSizeC * ones(1, wholeBlockCols), rem(columns, blockSizeC)];
ca = mat2cell(I, blockVectorR, blockVectorC);
imresize
– obchardon