Query on Zernike moments as library feature

Hi skimage team,

Myself, Ashu. Very happy to have a python library solely focused on traditional CV. I wanted to ask about Zernike moments (ZMs) as feature descriptors. As far as I know, there is no implementation in the skimage library. I have searched ‘zernike’ keyword on the website, in skimage forum, Zulip chat, issues on github, my recent forked repo of skimage. Couldn’t find any mentions or results. Is it being implemented currently, or maybe skimage2? Was it planned in the past then dropped from the library for some reason?

ZMs are used extensively in optical systems for aberration corrections, where I learned these. I have read the issue #4375 (Show and tell) on GH and see people using skimage for microscopy, shape, defect analysis etc. Assuming there is a need and it’s not being developed, will the community be interested in Zernike moments as a new library feature? If so, I would like to develop it, or help if someone is developing it.

Zernike moments refresher: Given an image, a unit circle centered over the image/object (circular pupil in optical systems, circular bounding box in object detection), Zernike moments are image weighted average of Zernike polynomials. There are three terms here: polynomials are complex valued basis functions which iterate over frequencies (cos(1,2,..,Mθ)); moments are image/object pixel intensities weighted average of these polynomials; features are magnitude of these complex moments. Degree n is a design parameter for the user, and fitting a degree n polynomial gives a feature vector of length (n+1)*(n+2)/2. So a degree=9 will give to the user a feature vector of length 55 with values between 0 and 1 (normalized).

For development and library features, and assuming not being developed by someone, I have the following in mind:

  • Develop the base Zernike moments (zernike.py) using pure python. This is to familiarize myself with the skimage contribution standards and procedures. I will implement feature, interface, documentation, references, tests, examples etc., then generate a PR. Please critique any minor to major changes. For the math heavy work, I want to ask if someone can verify the implementation.
  • Develop the cython extension for faster computation. Here I will need help from the core team as I am not quite familiar with cython and skimage build process. I will provide a working extension (zernike_cy.pyx), but will need help optimizing it. If we imagine a user iterating through thousands of images/objects, the aim is to compute the features very fast (<1s per image/object).
  • Once the base Zernike is optimized and finished, I have 4/5 more Zernike related library features in mind. If interested, I will build these and we can gradually roll out.

Please let me know if this would be something community is interested in, how would you like to proceed, your thoughts on development, and anything else.

Thanks,
Ashu

1 Like

A long while back I had a need for Zernike moments and I wished there was a library that had them implemented. It’s one of those things that are good to have just in case.