Hu Moments of order up to 3 measurement of a shape This measure computes the Hu moment invariants for each shape. The moments are calculated according to https://en.wikipedia.org/wiki/Image_moment#Moment_invariants.
Here is an example of Hu moment measurement in 2d case :
Hu Moments of order up to 3 measurement of a shape
Measure synthesis :
Measure Type | Measure Unit Type | Parameter Type | Result Type | Shape Requirements |
Geometry 2d
|
None
|
HuMoments2dMsrParams |
Custom
|
Boundary Approximation
|
See Shape measurement for additional information on these pictograms Example of Python code :
Generic example in 2d case :
import PyIPSDK
import PyIPSDK.IPSDKIPLShapeAnalysis as shapeanalysis
inMeasureInfoSet2d = PyIPSDK.createMeasureInfoSet2d()
PyIPSDK.createMeasureInfo(inMeasureInfoSet2d, "HuMoments2dMsr")
outMeasureSet = shapeanalysis.labelAnalysis2d(inGreyImg, inLabelImg2d, inMeasureInfoSet2d)
PyIPSDK.saveCsvMeasureFile(os.path.join(tmpPath, "shape_analysis_results.csv"), outMeasureSet)
outMsr = outMeasureSet.getMeasure("HuMoments2dMsr")
outMsrValues = outMsr.getMeasureResult().getColl(0)
print("First label i1 Hu moment measurement equal " + str(outMsrValues[1].i1()))
Example of C++ code :
Example informations
Associated library
IPSDKIPLShapeAnalysis
Code Example
Shape2dCollPtr pShape2dColl = boost::make_shared<Shape2dColl>();
IPSDK_REQUIRE(readFromXmlFile(inputShape2dCollPath, *pShape2dColl) == true);
MeasureInfoSetPtr pMeasureInfoSet = MeasureInfoSet::create2dInstance();
createMeasureInfo(pMeasureInfoSet, "HuMoments2dMsr", createHolesBasicPolicyMsrParams(bProcessHoles));
MeasureSetPtr pOutMeasureSet =
shapeAnalysis2d(pInGreyImg2d, pShape2dColl, pMeasureInfoSet);
const MeasureConstPtr& pHuMoments2dOutMsr = pOutMeasureSet->getMeasure("HuMoments2dMsr");
const HuMoments2dMsrResults& outResults = static_cast<const HuMoments2dMsrResults&>(pHuMoments2dOutMsr->getMeasureResult());