Measure allowing to compute the second order moment ponderated by the gray level of each pixel for shape.
The GreyInertia measurement computes the second order central moment for each shape, ponderated by the voxels intensities, thanks to the inertia matrix
.
Whose the components are computed as follows :
Where
is the image intensity at the position
,
,
and
are the grey barycenter coordinates (see GreyBarycenter) and
is the voxel collection of the current shape.
From these composents, three descriptors are extracted in 2d : the minimum and maximum eigen values of
(
and
) and the shape orientation
.
These features are calculated as follows :
and
are proportional to the squared length of the eigenvector axes, represented by green arrows in the figure below.
In 3d case, other features are available. They are calculated as follows :
Where :
And
Moreover, the 2d rotation angle
is replaced by the 3d rotation angles
,
and
, calculated with the coefficients of
:
Here is an example of the grey inertia calculated from a 2d input image :
Measure allowing to compute the second order 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, "GreyInertiaMsr")
outMeasureSet = shapeanalysis.labelAnalysis2d(inGreyImg, inLabelImg2d, inMeasureInfoSet2d)
PyIPSDK.saveCsvMeasureFile(os.path.join(tmpPath, "shape_analysis_results.csv"), outMeasureSet)
outMsr = outMeasureSet.getMeasure("GreyInertiaMsr")
outMsrValues = outMsr.getMeasureResult().getColl(0)
print("First label inertia mxx component measurement equal " + str(outMsrValues[1].mxx()))
Generic example in 3d case :
import PyIPSDK
import PyIPSDK.IPSDKIPLShapeAnalysis as shapeanalysis
inMeasureInfoSet3d = PyIPSDK.createMeasureInfoSet3d()
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d, "GreyInertiaMsr")
outMeasureSet = shapeanalysis.labelAnalysis3d(inGreyImg, inLabelImg, inMeasureInfoSet3d)
PyIPSDK.saveCsvMeasureFile(os.path.join(tmpPath, "shape_analysis_results.csv"), outMeasureSet)
outMsr = outMeasureSet.getMeasure("GreyInertiaMsr")
outMsrValues = outMsr.getMeasureResult().getColl(0)
print("First label inertia mxx component measurement equal " + str(outMsrValues[1].mxx()))
Example of C++ code :
Example informations
Associated library
IPSDKIPLShapeAnalysis
Code Example
Shape2dCollPtr pShape2dColl = boost::make_shared<Shape2dColl>();
readFromXmlFile(inputShape2dCollPath, *pShape2dColl);
MeasureInfoSetPtr pMeasureInfoSet = MeasureInfoSet::create2dInstance();
createMeasureInfo(pMeasureInfoSet, "GreyInertiaMsr");
MeasureSetPtr pOutMeasureSet =
shapeAnalysis2d(pInGreyImg2d, pShape2dColl, pMeasureInfoSet);
const MeasureConstPtr& pGreyInertiaOutMsr = pOutMeasureSet->getMeasure("GreyInertiaMsr");
const GreyInertiaMsrResults& outResults = static_cast<const GreyInertiaMsrResults&>(pGreyInertiaOutMsr->getMeasureResult());