MATLAB: How to compare regions of two differents images

arraycompareimageImage Processing Toolboxmatrixregionprops

Hello !
I have some difficulties with my program.
I would like to compare the area of some regions from a image with the area of regions from another image. I also would like to show the 1st image, only if the area is smaller than the area of the other image.
For example, cc1 = bwconncomp(Image1); % binary image
cc2 = bwconncomp(Image2);
stats1 = regionprops(cc1, 'Area'); %collects param
Area1 = [stats1.Area];% transfer area param
stats2= regionprops(cc2, 'Area');
Area2 = [stats2.Area];
idxArea = find(Area2 > Area1);
MatrixClean = ismember(labelmatrix(cc2), idxArea);
figure, imshow(MatrixClean), title('final image');
Someone can help me ? please ! I have this error : "Matrix dimensions must agree" but I don't know how to do that.
Have a nice day !

Best Answer

The code is not working because you don't have the same number of objects in each image, like youi have 10 blobs in one image and 35 blobs in the other image. Please post your binary images.