MATLAB: Dividing a figure into regions

image processingImage Processing Toolbox

Hello,
I am trying to divide the figure below regions as R1, R2, R3…etc such that each region is specified as a matrix

Best Answer

You can get all the regions with bwlabel().
[labeledImage, numRegions] = bwlabel(binaryImage);
Each region will have a label number in the labeledImage. You're going to have to pick out the three you want based on their label number. You can use ismember() for that.
threeRegions = ismember(labeledImage, [3,4,7]); % or whatever numbers they happen to be.