MATLAB: How to divide an image into 4*4 blocks and find the mean of each block

depthmap generationdividing image into blocksmean of blocks

we are doing our graduation project on depth map generation.we have read an coloured image and converted it into a grsay scale.next we have to divide the image into 4*4 blocks and find the mean of each block.

Best Answer

Img = rand(640, 480); % Test data
Img = reshape(Img, 4, 160, 4, 120);
meanImg = sum(sum(Img, 1), 3) / 16;
meanImg = squeeze(meanImg)