I'm working with an algorithm to detect symmetries in an irregular object, I'm using only Python with nunmpy and matplotlib, no possibility to use OpenCv, after I rotate my object along the principal axes, I get something like that rotated image
Then I wrote an algorithm which evaluate horizontal and vertical symmetries and make an average of the two:
def symmetry(self, mat):
mat is the matrix of coordinates of the points of my binary image
coords = np.around(mat) #coordinates are rounded
i, j = coords.shape
x, y = coords
horizontal = 0
vertical = 0
for k in range(j):
for m in range(k, j):
if(x[k] == x[m] and y[k] == -y[m]):
horizontal += 1
if((x[k] == -x[m] and y[k] == y[m]):
vertical += 1
symmetry = (horizontal + vertical)/ j
print('The symmetry index is:')
print(symmetry)
return
Since I wanted to evaluate the symmetry counting if each pixels has a correspondent with respect to the horizontal and the vertical axis I rounded the coordinates to integers, the problem is that if I test my algorithm with a cirlce, from which I expect perfect symmetry, I get about 0.5, the maximum value should be 1. Can somebody suggest a better metrics for evaluating the symmeytry in this situation or improve my code, In your opininon my solution should work?