Measure allowing to compute the zeroth to the third moment ponderated by the gray level of each pixel for shape.
The GreyMoments measurement computes the
,
,
and
order scale-invariant central moment for each shape, ponderated by the voxels intensities.
The central moment
for a given 2d shape
are computed by :
Where
are the coordinates of the shape grey barycenter (see GreyBarycenter).
The corresponding scale-invariant central moment
is calculated by normalizing
as follows : The central moment
for a given 2d shape
are computed by :
The central grey moments for a 3d shape are computed using the same formula, using the z-axis in addition to the x and y axises [1] :
Where the grey 3d shape barycenter has coordinates
.
The scale-invariant 3d moments can be obtained with the following equation :
Here is an example of 2d grey moment measurement :
References
[1] "Moments and Moment Invariants in Pattern Recognition, Chap. 2 Moment Invariants to Translation, Rotation and Scaling",Flusser, J.; Suk, T. & Zitova, B., John Wiley & Sons, Ltd, 2009, 13-47
Measure allowing to compute the zeroth to the third moment ponderated by the gray level of each pixel for shape
Measure synthesis :
Measure Type | Measure Unit Type | Parameter Type | Result Type | Shape Requirements |
Intensity
|
None
|
None
|
Custom
|
Row Intersections
|
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, "GreyMomentsMsr")
outMeasureSet = shapeanalysis.labelAnalysis2d(inGreyImg, inLabelImg2d, inMeasureInfoSet2d)
PyIPSDK.saveCsvMeasureFile(os.path.join(tmpPath, "shape_analysis_results.csv"), outMeasureSet)
outMsr = outMeasureSet.getMeasure("GreyMomentsMsr")
outMsrValues = outMsr.getMeasureResult().getColl(0)
print("First label first grey moment measurement equal " + str(outMsrValues[1].getMoment(shapeanalysis.GreyMomentsData.eGreyMoment3Id.eGM3I_X0Y0Z0)))
Generic example in 3d case :
import PyIPSDK
import PyIPSDK.IPSDKIPLShapeAnalysis as shapeanalysis
inMeasureInfoSet3d = PyIPSDK.createMeasureInfoSet3d()
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d, "GreyMomentsMsr")
outMeasureSet = shapeanalysis.labelAnalysis3d(inGreyImg, inLabelImg, inMeasureInfoSet3d)
PyIPSDK.saveCsvMeasureFile(os.path.join(tmpPath, "shape_analysis_results.csv"), outMeasureSet)
outMsr = outMeasureSet.getMeasure("GreyMomentsMsr")
outMsrValues = outMsr.getMeasureResult().getColl(0)
print("First label (X0, Y0, Z0) moment measurement equal " + str(outMsrValues[1].getMoment(shapeanalysis.GreyMomentsData.eGreyMoment3Id.eGM3I_X0Y0Z0)))
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, "GreyMomentsMsr");
MeasureSetPtr pOutMeasureSet =
shapeAnalysis2d(pInGreyImg2d, pShape2dColl, pMeasureInfoSet);
const MeasureConstPtr& pGreyMomentsOutMsr = pOutMeasureSet->getMeasure("GreyMomentsMsr");
const GreyMomentsMsrResults& outResults = static_cast<const GreyMomentsMsrResults&>(pGreyMomentsOutMsr->getMeasureResult());