Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Moments function in opencv

Tags:

c++

opencv

When finding the center coordinates using moments in OpenCV,the point is found using

Point(moment[i].m10/moment[i].m00,moment[i].m01/moment[i].m00);

Can somebody please explain this bit to me?What do "m10","m00","m01" and "m00" mean??

like image 609
Steph Avatar asked Mar 18 '14 05:03

Steph


People also ask

What are moments of an image?

In image processing, computer vision and related fields, an image moment is a certain particular weighted average (moment) of the image pixels' intensities, or a function of such moments, usually chosen to have some attractive property or interpretation. Image moments are useful to describe objects after segmentation.

What are the 7 Hu moments?

Hu Moments ( or rather Hu moment invariants ) are a set of 7 numbers calculated using central moments that are invariant to image transformations. The first 6 moments have been proved to be invariant to translation, scale, and rotation, and reflection. While the 7th moment's sign changes for image reflection.

What is cv2 findContours?

Output: We see that there are three essential arguments in cv2. findContours() function. First one is source image, second is contour retrieval mode, third is contour approximation method and it outputs the image, contours, and hierarchy. 'contours' is a Python list of all the contours in the image.

What is cv2 approxPolyDP?

Working of approxPolyDP() function in OpenCV We make use of a function in OpenCV called approxPolyDP() function to perform an approximation of a shape of a contour. The image of a polygon whose shape of a contour must be approximated is read using the imread() function.


1 Answers

Definition of moments in image processing is borrowed from physics. Assume that each pixel in image has weight that is equal to its intensity. Then the point you defined is centroid (a.k.a. center of mass) of image.

Assume that I(x,y) is the intensity of pixel (x,y) in image. Then m(i,j) is the sum for all possible x and y of: I(x,y) * (x^i) * (y^j).

Here you can read the documentation of moments used in OpenCV. They are called raw moments.

And here you can read a wiki article about all kinds of image moments (raw moments, central moments, scale/rotation invariant moments and so on). It is pretty good one and I recommend reading it.

like image 150
Michael Burdinov Avatar answered Sep 27 '22 01:09

Michael Burdinov