MATLAB: How to divide an image with unequal size into 4 x 4 non-overlapping blocks.

non overlappingunequal size

an image with unequal size shoud be divided into 4 x 4 non-overlapping blocks.

Best Answer

This code will convert the 3 channel inImage into 16 patches and save them in a cell array
mat2cell(inImage, size(inImage,1)/4*ones(4,1), size(inImage,2)/4*ones(4,1), 3)