dextervip
dextervip

Reputation: 5059

How to divide an image into 8 regions using Matlab

I have 256x256 image, Is there any easy way to divide it into 8 regions(32x32) and get a specific region? Ex.: region 4,6

Upvotes: 0

Views: 1268

Answers (1)

mwengler
mwengler

Reputation: 2778

An image is stored as a 2-dimensional array.

function region = fnGetRegion(C,I,J);
% C is 256x256 image, I, J each range 1:8 to get 32x32 subregion of C
region = C((I-1)*32+[1:32],(J-1)*32+[1:32]);
end

Upvotes: 3

Related Questions