Happy Shrimp
http://blog.csdn.net/lights_joy/
Welcome reprint, but please keep the author information
The geometric moment is theHuin the1962with translational, rotational, and scale invariance. OpenCVThe calculation of the moment is determined byC + +in theMomentsThis class comes complete with:
//! Raster image Momentsclass Cv_exports_w_map moments{public: //! The default constructor Moments (); //! The full constructor Moments (double m00, double M10, double m01, double M20, double M11, double m02, double M30, D Ouble M21, double M12, double m03); //! The conversion from cvmoments Moments (const cvmoments& Moments); //! The conversion to cvmoments operator cvmoments () const; //! Spatial Moments CV_PROP_RW double m00, M10, M01, M20, M11, M02, M30, M21, M12, M03; //! Central Moments CV_PROP_RW double mu20, Mu11, mu02, Mu30, Mu21, Mu12, mu03; //! Central normalized moments CV_PROP_RW double nu20, Nu11, nu02, Nu30, Nu21, Nu12, nu03;};
It can be seen that it mainly includes the space moment, the center moment and the center normalized moment.
I've never been too sure. Geometric moments can play a role in plant leaf identification, especially for occluded leaves. But just to learn here, try to calculate Hu moments under Python .
The images used are the color images that were split up before:
We've got a two value image of them:
We use these two two-value images as the input image for the moment.
#-*-coding:utf-8-*-import cv2import numpy as Np#import matplotlib.pyplot as Pltdir = ' F:\\projects\\src\\opencv\\imag Es\\cotton\\ '; # Hu invariant Moment # read cotton image cotton = cv2.imread (dir + ' 39.mask.jpg ') cotton = cotton[:,:,0] # This is a two value image, Take only the first channel cv2.imshow (' Cotton ', cotton) # read weed image weed = cv2.imread (dir + ' 47.mask.jpg ') weed = weed[:,:,0] # This is a two value image, Take only the first channel cv2.imshow (' Weed ', weed) # Calculate the moment of cotton and hu moment moments = cv2.moments (cotton) hu_moments = Cv2. Humoments (Moments) print (' Cotton moments: ') print (hu_moments) # Calculates the moment of weed and hu moment moments = cv2.moments (weed) hu_moments = Cv2. Humoments (Moments) print (' Weed moments: ') print (hu_moments) Cv2.waitkey ()
The results are calculated as follows:
just two pictures doesn't really explain the problem, just show it by the code above Python Calculation Hu The way of the moment, that's all.
??
Python image Processing (9): Hu Moment