mahotas icon indicating copy to clipboard operation
mahotas copied to clipboard

different shape has the same Zernike moments value

Open mashuai191 opened this issue 4 years ago • 4 comments

11_circle 21_circle

as picture shows the i have two different shapes (one is part of the other), but it's strange that i got the same Zernike moments for them when i only use same parameter of center of mass and radius (see the green circle) . I don't know the Zernike foundamentals, so is this reasonable or an issue?

please ignore the green circle and red contour, that's drawed only try to make this question clear. the two original images only have the white object.

mashuai191 avatar Dec 01 '19 14:12 mashuai191

Thanks for the report. Could you post some code and the images where you see this issue?

luispedro avatar Dec 02 '19 05:12 luispedro

I mean the original images so I can run the example locally without the red and green contours.

luispedro avatar Dec 02 '19 05:12 luispedro

!pip install mahotas import mahotas import numpy as np from google.colab.patches import cv2_imshow # this is for google colaborator env, you can use cv2.imshow() instead

thresh = None img = cv2.imread('your_path/11.png',cv2.IMREAD_GRAYSCALE) ret,thresh = cv2.threshold(img,127,255,cv2.THRESH_BINARY) img,contours,hierarchy = cv2.findContours(thresh.copy(), 1, 2)

cnt = sorted(contours, key = cv2.contourArea, reverse = True)[0] (x,y),radius = cv2.minEnclosingCircle(cnt) center = (int(x),int(y)) radius = int(radius) print (center, radius)

z_im = mahotas.features.zernike_moments(thresh, radius, cm=center) print (z_im)

and original pic is as following:

11 21

mashuai191 avatar Dec 02 '19 05:12 mashuai191

@luispedro did you got the same result for those two images? Thanks a lot!

mashuai191 avatar Dec 03 '19 06:12 mashuai191