Code covered by the BSD License  

Highlights from
The Seven Invariant Moments

3.75
3.8 | 10 ratings Rate this file 72 Downloads (last 30 days) File Size: 234 KB File ID: #33975

The Seven Invariant Moments

by

 

Calculates the Seven Invariant Moments in terms of centralized Moments

| Watch this File

File Information
Description

Two function files that can be applied on an image to calculate the seven invariant moments defined by Hu(1962)in terms of centralized Moments for purpose of shape recognition . The function to be used directly by the user is
feature_vec(A),where A is a 2D matrix representing an image.
Inside this function another function :cent_moment(p,q,A)is called to calculate the normalized central moments
You can use it in separate.But you don't need to do so when using feature_vec(A)
Attached with the two functions is a pdf file containing short mathematical notes about the theory of Invariant Moments.

Required Products MATLAB
MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (14)
21 Jan 2015 Jess

Jess (view profile)

If A is grayscale(uint8), feature_vec return all zero. If A is grayscale(double), feature_vec return some values.
If A is logical, feature_vec return some values as well.

Comment only
06 Nov 2014 Adam Drake

Caution: This file kills my Matlab. It has serious optimisation issues.

30 Jun 2014 andrey

andrey (view profile)

I have the same problem as Try_me34, moments are always zero.
Also the inefficiency of this algorithm makes it practically unusable (I suspect it has a NN or larger order-of-growth).

Comment only
20 Feb 2014 Jess

Jess (view profile)

 
14 Dec 2013 Try_me34

Hi, the M always returns zeros ( M1=0 M2=0 .. M7=0).
Am I missing something here?

Comment only
05 Dec 2013 Henryk Richter

Thanks for the contribution, the code is quite readable and nicely done.

After tinkering with images, that have been rotated/scaled/translated, I noted some discrepancies between theoretically identical results and your script's output. The following lines in fecture_vec.m need to be corrected to:

M5=(n30-3*n12)*(n30+n12)*[(n30+n12)^2-3*(n21+n03)^2]+(3*n21-n03)*(n21+n03)*[3*(n30+n12)^2-(n21+n03)^2];

M7=(3*n21-n03)*(n30+n12)*[(n30+n12)^2-3*(n21+n03)^2]+(3*n12-n30)*(n03+n21)*[ 3*(n30+n12)^2-(n21+n03)^2 ];

I got the formulas from "Digital Image Processing" by Gonzalez/Woods (and they work just fine) but didn't verify with Hu's paper.

02 Oct 2013 wahyu

wahyu (view profile)

very good

18 Oct 2012 Elvis Condori

Muy buena contribuciĆ³n.

13 Aug 2012 Long

Long (view profile)

 
19 Jun 2012 Omid

Omid (view profile)

 
12 Mar 2012 Ishrat Badami  
12 Mar 2012 Ishrat Badami  
10 Mar 2012 Ishrat Badami

Lot of redundant calculations. Also instead of using lot of for loops you can try efficient matrix multiplication.

08 Feb 2012 shobhit

ans this pls
http://www.mathworks.in/matlabcentral/answers/28455-image-feature-extraction-using-invariant-moments

Comment only

Contact us