How to find the /check whether the image is symmetry or not ??

46 views (last 30 days)
I looking into a way to check the whether the given image is symmetry or not ?? For e,g, attached figure.
Note - All of my images are in irregular circular shape, the idea is to quantify how far it from the symmtericity..

Answers (1)

Star Strider
Star Strider on 3 Jun 2021
See my Answer to your other Question.
BTW, I am intend to find the symmtery in the image, for e.g. finding symtericity about y axis in the case of attached figure, Have you dealth anything similar to this ??
I have not. However it doesn’t appear to me to be symmetrical. One option may be to use the centroid function (introduceed in R2017b) to get the (x,y) coordinates. You can then use the ‘x’ value to calculate the symmetry. I am not certain how best to define ‘symmetry’ or test for it.
On an interweb search, I was only able to find one File Exchange contribution that might be useful: Novel Method for Determining Symmetry of Skin Lesions using the Jaccard Index, so it woould likely be worthwhile to search the File Eschange to see if there are others that could apply to what you want to do.
Taking a stab at this just for fun, using the ‘x{1}’ and ‘y{1}’ results from my previous Answer
ps1 = polyshape(x{1},y{1}); % Create Polyshape Object
[xc,yc] = centroid(ps1) % Centroid
flipcurv = x{1}<=xc; % Logical Indices To Left Of Centriod ‘x’ Value
xfc = xc - x{1}(flipcurv); % Flipped ‘x’-Coordinates
yfc = y{1}(flipcurv); % Corresponding ‘y’-Coordiantes
xrc = x{1}(~flipcurv)-xc; % Right-Hand-Side Of Contour ‘x’-Coordinates (Not Flipped)
yrc = y{1}(~flipcurv); % Right-Hand-Side Of Contour ‘y’-Coordinates (Not Flipped)
ang1 = atan2(yfc-yc,xfc); % Angles
r1 = hypot(yfc-yc, xfc); % Radii
[Uar1,ar1ix] = unique([ang1(:),r1(:)], 'rows'); % Unique [Angles Radii]
afi = linspace(min(Uar1(:,1)), max(Uar1(:,1)), 1000); % Interpolation Vector
rfi = interp1(Uar1(:,1), Uar1(:,2), afi); % Interpolated Value
ang2 = atan2(yrc-yc,xrc); % Angles
r2 = hypot(yrc-yc, xrc); % Radii
[Uar2,ar2ix] = unique([ang2(:),r2(:)], 'rows'); % Unique [Angles Radii]
ari = linspace(min(Uar2(:,1)), max(Uar2(:,1)), 1000); % Interpolation Vector
rri = interp1(Uar2(:,1), Uar2(:,2), ari); % Interpolated Value
[r,p] = corrcoef(rfi(:),rri(:)); % Correlation (One Of Many Possible Measures Of Similarity)
[xfi,yfi] = pol2cart(afi,rfi); % Convert Back To Cartesian
[xri,yri] = pol2cart(ari,rri); % Convert Back To Cartesian
plot(xfc, yfc)
hold on
plot(xrc, yrc)
hold off
hold on
hold off
title('Interpolated & Re-Plotted Overlapped Curves')
legend('Flipped Left-Half', 'Original Right-Half', 'Location','best')
This code produces equal-length vectors (plotted) that can now be compared with each other in any number of ways. I defer to you to explore those options!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!