4.22222

4.2 | 9 ratings Rate this file 147 Downloads (last 30 days) File Size: 31.9 KB File ID: #38900
image thumbnail

Zernike Moments

by

 

05 Nov 2012 (Updated )

MATLAB Code for the Fast Calculation of Zernike Moments of order n and repetition m on NxN images.

| Watch this File

File Information
Description

This submission includes 3 mfiles and 6 image files:
1- Zernike_main.m (The main script that takes care of everything)
2- Zernikmoment.m (Calculates the Zernike moments for an NxN ROI)
3- radialpoly.m (Calculates the radial polynomials which are prerequisites for calculating Zernike moments)
4- Six .png files to test the code.

When you run the Zernike_main.m, it will calculate the Zernike moments of order n=4 and repetition m=2 for the input images. Since the first row images are just the rotated versions of a unique object (oval), the magnitudes of the Zernike moments for these three images are the same. In addition, the differences between the phases of the moments are proportional to the rotation angles of the images. Expectedly, the Zernike moments of two different shapes (e.g. oval and rectangle) are totally different. The reason of this behavior is the ability of Zernike moments in describing the shape of objects.

To acknowledge the use of the code please cite:

A. Tahmasbi, F. Saki, S. B. Shokouhi, Classification of Benign and Malignant Masses Based on Zernike Moments, J. Computers in Biology and Medicine, vol. 41, no. 8, pp. 726-735, 2011.

A. Tahmasbi, F. Saki, H. Aghapanah, S. B. Shokouhi, A Novel Breast Mass Diagnosis System based on Zernike Moments as Shape and Density Descriptors, in Proc. IEEE, 18th Iranian Conf. on Biomedical Engineering (ICBME'2011), Tehran, Iran, 2011, pp. 100-104.

Required Products MATLAB
MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (31)
31 Jul 2014 Amir Tahmasbi

Hi Frederik,

Thank you for your interest in my code. I have addressed your concerns as follows:

1- Regarding “Product = p(x,y).*Rad.*exp(-1i*m*Theta);” I should say this is actually correct. Remember that the Zernike moments are calculated by multiplying the input image p(x,y) and the complex conjugate of 2-D Zernike basis functions (typically denoted by V_n,m = R_n,m(\rho) . exp(j m \theta). In other words, we have “Product = p(x,y) V*_m,n = p(x,y) . R_n,m(\rho) . exp( - j m \theta)” .The negative sign that you are refereeing to is, therefore, added due to the complex conjugate operator. For a clearer explanation please see my paper, p. 730, eq. 11 (available on-line at http://www.utdallas.edu/~a.tahmasbi/publications/Zernike_CBM_2011.pdf ). Also you can take a look at the classic paper on Zernike moments by Dr. Khotanzad, p. 490, eq. 5 (available on-line at http://optics.sgu.ru/~ulianov/Bazarova/LASCA_literature/InvariantImageRecognitionZernikeMoments.pdf ). You can further verify this using eq. 49 in the web page you sent me.
2- You are right. The mapping we have used in the code, loses the information of the corners of the image. This is, however, a common mapping strategy from the image space into the unit disk that researchers typically use for the calculation of the Zernike moments (see e.g. Dr. Khotanzad’s paper above). From a practical point of view, it usually does not cause any problem since the object of interest is scaled such that it is circumscribed by the unit disc.
3- The code can easily be generalized to the non-square shaped ROIs. Since this is a questions that many other people have also asked, I will update the code on the MATLAB central page for rectangular shaped images when I get a chance (probably in a few weeks). You can also do it yourself.
4- I can make some MxN test image sets, but I will need some time to do this. You can also make those images using the square images I put on the MATLAB central page (just add say 5 rows above and below the ROI). Then, you can rotate the object within the same ROI and verify if the magnitudes of the moments remain the same.

29 Jul 2014 Frederik

Hello Amir,
first of all, thanks for sharing your code.
secondly i would like to ask a question, in which i dont know if i make a mistake or you did in your code.

Product = p(x,y).*Rad.*exp(i*m*Theta)
to calculate the complex polynominal in all the formulars i found
(e.g: http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/SHUTLER3/node11.html )
its written that j = sqrt(-1);
you wrote in your code -1*i instead, which is not the same. because sqrt(-1) is just the definition of the complex number to be i. so am i wrong or should it be:

Product = p(x,y).*Rad.*exp(i*m*Theta)

in your code, without the -1?

i hope its understandable what i want to say.

tanks again, frederik

01 Jun 2014 fathi  
21 Apr 2014 fateme

Thank you

27 Nov 2013 Dimitris Tsolakidis

Hello Amir. Thank you for your code. I have used your code to calculate zernike moments from an image, but i'm having problem reconstruct the image from it's moments. Could you provide me some help please?

19 Sep 2013 mariem farhat

Another question:

1. your code assume that the image is square; and if it wasn't?

2. I don't understand Product = p(x,y).*Vnm? why not Product = p.*Vnm;

19 Sep 2013 mariem farhat

Thank you for the code.
But why in the image mapping you use (2.*X-N-1) and not (2.*X-N)?

Thank you!

19 Sep 2013 mariem farhat  
21 Aug 2013 MUTHU RAM

Actually want to find the global features with zernike moments of the image but dono how to proceed with it??

20 Aug 2013 MUTHU RAM

can Any one say how to find the Zernike moments for rgb image...Thanks in advance

09 Aug 2013 dana Wang

Hi Tahmasbi,
Thank you for your code. can u please hepl me to modify your code substituding p(x/a+x1,y/a+x2) to p(x,y),where p(x,y) is original image, x1 and x2 are the centroid of p(x,y),x1=m10/m00,x2=m01/m00,a=sqrt(β/m00),β is a predetermined value. In fact, this is doing scale and translation normalization. Thank you very much.

23 Jul 2013 Amir Tahmasbi

Hi Mitra,

1- It mainly depends on your application and you need some experience to pick the appropriate order (n) and repetition (m) for your moments. However, the rule of thumb is that the lower orders provide less information (details) but are more robust to noise. Higher orders, on the other hand, provide more information about the details of the object but are more sensitive to the measurement noise. An efficient way is to calculate the Zernike moments for a variety of m and n values. You may then apply a feature selection algorithm and remove the correlated features (moments). You can finally use a group of say 20 moments, which are reasonably uncorrelated, to pass to your classifier.

2- I think with appropriate preprocessing steps, the Zernike moments should be useful for Farsi digit recognition.

Regards,
Amir

18 Jul 2013 mitra Isaei

oh, excuse me. I understand my answer.
but I have other questions:
1.How do I understand What values are appropriate for Assignment to n and m?
I'm using zernike moment for handwritten farsi digits recognition.
2. Are features that obtain from Zernike moments, useful for classification in handwritten farsi digits recognition?

18 Jul 2013 mitra Isaei

hi sir
your code calculates one Zernike moment and its magnitude. how to change this code to calculate more Zernike moments.
thanks

11 Jul 2013 Amir Tahmasbi

Hi Shriniwas,

Yes, the code is capable of calculating the Zernike moments of any order and repetition. All you need to do is change m (repetition) and n (order). The default ones are n=4 and m=2. Hope this helps.

Cheers,
Amir

02 Jul 2013 Shriniwas Chavan

Sir I am using zernike moment for handwritten character recognition, I have applied zernike moment in terms of geometric moment, but it is upto 3 and 4 order, i want to extend the code can your files can extend it or extract zernike moment

16 Jun 2013 Reyadh

Hi Amir
thanks for replay
I know what you say
now almost I have identification for some plamprints
I used high zernike order
and better database
also i maked unit disk for pic
I will make some addition and see what happen
Thanks you

13 Jun 2013 Amir Tahmasbi

Hi Reyadh,

In principle, the Zernike moments can be extracted from any shape. However, in your case, there could be a variety of potential issues. First of all, you need to make sure the objects (palm prints) are of equal size within the ROI. If not, you need to equalize the size of your objects in all ROIs.

The other thing is that the palm prints are more complicated object than simple shapes, e.g. oval and circle. Thus, you might need to extract a set of higher order Zernike moments. You can then use these moments to classify the palm prints of different people more reliably.

FYI, the magnitude of the Zernike moments of two similar shapes might be slightly vary due to the pixelation and noise. But the difference should be insignificant.

Cheers

08 Jun 2013 Reyadh  
08 Jun 2013 Reyadh

hello Tamanna
I used your zernike to find zernike moment for palmprint
but there are some problem
when use for that A=0,Theta=0
I make some changed to the code
I replaced p = logical(not(p));
to p=im2double(p);
and it is work after that with palmprint and your pics nad values equal with yours
but the problem the values does not equal for same person palmprint
any help?
thanks

04 May 2013 Amir Tahmasbi

Hi Tareq

Thanks! The input arguments "m" and "n" are scalars. This means that if you would like to extract say 32 moments, you need to have a "for loop" in which you change "n" and "m", and call the Zernikemoment(p, n, m). Depending on your application you can either change "n" from y to 32+y or use different combinations of "m" and "n". For more information, see Table 1 in page 731 of this article:

http://www.utdallas.edu/~a.tahmasbi/publications/Zernike_CBM_2011.pdf

Hope this helps.

30 Apr 2013 Frb  
30 Apr 2013 Tareq Al-Zubaidi

nice job,,, one question, if we say 32 moments so i expect when I call [ZOH AOH PhiOH] = Zernikmoment(p,n,m);

the ZOH to be an array of 32 ? or what 32 moments mean here ?

15 Apr 2013 Amir Tahmasbi

Hi Tamanna,

The Zernike moments are rotation-invariant, no question on it! So, if you use the sample pictures included in the package, you will see this feature.

The reason that you are getting different results for the abs of Zernike moments is explained as follows. The MATLAB function "imrotate" does not preserve the size of an object in the ROI. Please note that the ROI size will be the same but the original image will be shrank in the new ROI. Thus, you are changing the object size that alters the abs of the Zernike moments. Hope this helps.

Regards,
Amir

10 Apr 2013 tamanna

hey..can u please help me to identify that how this code is invariant to rotation..

because if i apply 'imrotate' with 30 or 45 degree on an image, then the result is different.

02 Apr 2013 Amir Tahmasbi

Hi Anandh,

Yes, that is correct. By changing 'n' you can change the order of the Zernike moments to generate a set of say 32 features. However, you should keep in mind that also the variable 'm' (i.e. the repetition of moments) plays an important rule in the behavior of the moments. Hence, 'm' should be selected adaptively by changing 'n'. To find a suitable repetition for your proposed order, please see:

http://www.utdallas.edu/~a.tahmasbi/publications/Zernike_CBM_2011.pdf

Hope this helps! Let me know if you have any other concerns.

Regards,
Amir

02 Apr 2013 Anandh

Hi Amir,

Am new to this Zernike Moments. I tried to understand your code. I have few doubts. How to find 32 order features for a given image? Is it by varying the number 'n'? Please reply.

21 Dec 2012 Cobi Biton  
15 Nov 2012 Amir Tahmasbi

Thanks guys! Chris: I refer you to one of our papers in which we normalize the ROIs before extracting the Zernike moments (i.e. we remove the dependency of Zernike moments on the translation and scaling of object in the preprocessing step). Here it is:

http://www.utdallas.edu/~a.tahmasbi/publications/Zernike_CBM_2011.pdf

Another way is to use the Zernike moment invariants explained nicely here:

http://www.sciencedirect.com/science/article/pii/S0031320302003539

14 Nov 2012 Chris

Good job!And, how is the zernike moment invariants

06 Nov 2012 Fatemeh Saki

Nice job!! Thank you so much.

Updates
02 Jan 2013

Removed several minor mistakes in the description of the file.

21 Jan 2013

Rephrased the summary for clarity.

31 May 2013

Added more sample shapes with different rotation angles.

02 Oct 2014

Just updated the description.

Contact us