I am working on the MATLAB project, where the user will upload a scanned image of ellipse-like objects, and the program should calculate the measurements (height, width, area, etc.) of each object in the image.
I started with a threshold value that creates a binary image (black background and white independent objects). This is the BW image after the threshold:

After that, I used regionprops , since it returns most of the measurements I need, and it worked perfectly.
The problem is that the order in which the function "recognizes / detects" objects is incompatible. I added code to show the amount of each object, so that I can know which object has regionprops , which is considered as the first, and the second is the second .cc.
Code:
% read image rgb=imread('bw'); s = regionprops(bw,'Area', 'BoundingBox', 'Eccentricity', 'MajorAxisLength', 'MinorAxisLength', 'Orientation', 'Perimeter','Centroid'); % show the number of each object imshow(bw) hold on; for k = 1:numel(s) c = s(k).Centroid; text(c(1), c(2), sprintf('%d', k), ... 'HorizontalAlignment', 'center', ... 'VerticalAlignment', 'middle', 'color', 'r'); end hold off;
This image after showing the order of objects:

I need the order from top to bottom to bottom right. (the first row of objects is numbered from 1 to 6, the second row from 7 to 12..nets). Is it possible?
Thank you very much.