Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of the seven Hu invariant moments function from OpenCV

I understand that the seven hu invariant moments are for translation, rotation, and scale change of the object, in order to recognize the object independently these factors.

That's why I used the function "moments" from OpenCV to extract the central moments, then I used the function HuMoments to get the seven invariant moments of the following binarized image :

enter image description here

My first question is regarding the use of the function "moments" from OpenCV. The second parameter is "binaryImage" and I set it true, because it's a binary image, is it ok?

My second doubt is regarding the output of the function "HuMoments": the seven hu invariant moments. I don't understand this data. what data is related to rotation, what for translation and what for scale change?.

Many thanks!, cheers!

like image 243
andrestoga Avatar asked Jul 08 '12 01:07

andrestoga


1 Answers

First question :

It is ok to do so since you have single object in image. If more objects, and want to find moments for each, use contours. Visit : http://opencvpython.blogspot.in/2012/06/contours-3-extraction.html

Second Question :

(I am too thinking about it after seeing your questions)

HuMoments were brought to light by Mr.Ming Kuei Hu in his paper " Visual Pattern Recognition by Moment Invariants " in 1962.

In that paper, he explains them ( with help of high mathematics content, of course). You can check it if you need.

He states :

Theorem: The central moments are invariants under translation.

When you find the moments using moments() function, it returns three types of moments, spatial moments (Mji), Central Moments (MUji) and Central Normalized Moments ( NUji). Check out the docs for moments()

At the end of section 4-C, Hu states that, out of seven relations ( Visit here to see them), first six are invariant to translation, size and rotation, while seventh one is skew invariant, which helps to distinguish mirror images.

I searched a lot about what Hu Moments values means. But all papers says the same dialog : " Seven Hu Moments are calculated from Central Moments which are invariant to size, position and orientation ". They don't say what individual values mean.

And the classical book of OpenCV "Learning OpenCV" by Mr.Gary Bradsky has given some insights telling us to explore more. (Refer page 254)

like image 185
Abid Rahman K Avatar answered Nov 20 '22 03:11

Abid Rahman K