From the description, it appears that you wanted to isolate the figures (circles and squares) from the image and find out their positions and dimensions.
The first part of the question is to convert the image into a binary format to allow the command ‘regionprops’ to function properly.
This can be evaluated by –
im = imread('figCrop.png');
im = rgb2gray(im);
im1 = imcrop(im,[223 118, 1333, 1273]);
im2 = imbinarize(im1);
im3 = imfill(im2, 'holes');
J = medfilt2(im3,[15 15]);
Now, to evaluate the centroids and dimensions of the image using the command ‘regionprops’,
s = regionprops(J,'centroid');
centroids = cat(1,s.Centroid);
stats = regionprops('table',J,'Centroid',...
The structure ‘s’ now holds the information of all the centroids of the image. Note that there are a few additional centroids that have been identified incorrectly because of the noise in the image that couldn’t be cleared by median filtering i.e. ‘medfilt2’.
From the table ‘stats’, you now have the information of the positions of the objects and their corresponding dimensions.
Additionally, to calculate and plot the radii of the circles in the image, use the following code -
diameters = mean([stats.MajorAxisLength stats.MinorAxisLength],2);
radii = diameters/2;