MATLAB: How to divide an image into upper and lower regions

region properties

How to divide an image into upper and lower regions and get those into separate variables, based on the centroid point, so that i need to compute the area, separately.

Best Answer

I = imread('your image'); % read image
Ibw = im2bw(I);
Ilabel = bwlabel(Ibw);
stat = regionprops(Ilabel,'centroid'); % get centroid
imshow(I); hold on;
plot(stat.Centroid(1),stat.Centroid(2),'ro');
%%dive the image
c = fix(stat.Centroid) ;
I1 = I(1:c(1),:,:) ;
I2 = I(c(1)+1:end,:,:) ;
figure ; imshow(I1) ;
figure ; imshow(I2) ;