Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

different shape has the same Zernike moments value #109

Open
mashuai191 opened this issue Dec 1, 2019 · 4 comments
Open

different shape has the same Zernike moments value #109

mashuai191 opened this issue Dec 1, 2019 · 4 comments

Comments

@mashuai191
Copy link

mashuai191 commented Dec 1, 2019

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.

@luispedro
Copy link
Owner

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

@luispedro
Copy link
Owner

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

@mashuai191
Copy link
Author

!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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants