What is Image Moments?
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.
In openCV, it is used as
cv2.moments(cv2.contourArea(contours[i]))
Through this method, we can get
By the output, we can calculate
- Mass center($ \bar{x},\ \bar{y} $) : $ \bar{x}\ =\ \frac{m_{10}}{m_{00}},\ \bar{y}\ =\ \frac{m_{01}}{m_{00}}$
- Spatial moments : $ m_{ij}\ =\ \sum_{x,y}(array(x,y)*x^{i}y^{j}) $
- Central moments : $ mu{ij}\ =\ \sum_{x,y}(array(x,y)*(x-\bar{x})^{i}(y-\bar{y}^{j})) $
- Normalized central moments : $ nu_{ij}\ =\ \frac{mu_{ij}}{m_{00}^{\frac{i+j}{2}+1}} $