Measure allowing to compute Lowitz local histogram module.
This measure computes the local histogram module [1], of image pixel/voxel intensity values associated to a 2d/3d shape. The higher is the measure, the more homogeneous is the shape. Homogeneous shapes yields 1/NumericLimits<ipReal64>::epsilon().
This measure is based on the analysis of the shape histogram (see Histogram). Given the histogram parameters allowing to determine (among others) the number of classes
and a global range for the histogram, this measure is computed as the Mahalanobis distance between the actual histogram
and the theoretical histogram
for which each bin has the same value. This distance can be expressed as :
Where
is the number of classes in the histogram,
is the expected value of the
bin of the histogram
and
is its variance.
Let us define
as the value of the normalized histogram :
, with
being the number of pixels in the shape. Since this measure is based on Bernoulli distribution, the expected value of
and its variance are :
Moreover the expected value (and hence probability) and variance of the theoretical histogram
for each bin
are:
With
draws (1 per pixel in the shape), we can rewrite the Mahalanobis distance as follows :
Here is an example of energy measurement in 2d case :
References
[1] G. Lowitz "Can a Local Histogram Really Map Texture Information?". Pattern Recognition, 16, 2, 1983, pp 141–147.
Measure allowing to compute Lowitz local histogram module
Measure synthesis :
Measure Type | Measure Unit Type | Parameter Type | Result Type | Shape Requirements |
Generic
|
None
|
LocalHistogramModuleMsrParams |
Value (ipsdk::ipReal64)
|
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, "LocalHistogramModuleMsr")
outMeasureSet = shapeanalysis.labelAnalysis2d(inGreyImg, inLabelImg2d, inMeasureInfoSet2d)
PyIPSDK.saveCsvMeasureFile(os.path.join(tmpPath, "shape_analysis_results.csv"), outMeasureSet)
outMsr = outMeasureSet.getMeasure("LocalHistogramModuleMsr")
outMsrValues = outMsr.getMeasureResult().getColl(0)
print("First label measurement equal " + str(outMsrValues[1]))
Generic example in 3d case :
import PyIPSDK
import PyIPSDK.IPSDKIPLShapeAnalysis as shapeanalysis
inMeasureInfoSet3d = PyIPSDK.createMeasureInfoSet3d()
PyIPSDK.createMeasureInfo(inMeasureInfoSet3d, "LocalHistogramModuleMsr")
outMeasureSet = shapeanalysis.labelAnalysis3d(inGreyImg, inLabelImg, inMeasureInfoSet3d)
PyIPSDK.saveCsvMeasureFile(os.path.join(tmpPath, "shape_analysis_results.csv"), outMeasureSet)
outMsr = outMeasureSet.getMeasure("LocalHistogramModuleMsr")
outMsrValues = outMsr.getMeasureResult().getColl(0)
print("First label measurement equal " + str(outMsrValues[1]))
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, "LocalHistogramModuleMsr");
MeasureSetPtr pOutMeasureSet =
shapeAnalysis2d(pInGreyImg2d, pShape2dColl, pMeasureInfoSet);
const MeasureConstPtr& pLocalHistogramModuleOutMsr = pOutMeasureSet->getMeasure("LocalHistogramModuleMsr");
const ipsdk::shape::analysis::ValueMeasureResult<ipsdk::ipReal64>& outResults = static_cast<const ipsdk::shape::analysis::ValueMeasureResult<ipsdk::ipReal64>&>(pLocalHistogramModuleOutMsr->getMeasureResult());