measure allowing to compute number of neighbors of shapes given a distance threshold
This measure allows to compute number of neighbors of a shape given a user parameter distance threshold MaxDist (we count shapes for which distance is lower or equal to this value). It is based on a geometric analysis of shape neighborhood.
Parameter flag ProcessHoles allows to specify whether shape holes should be taken into account during computation. Please see Distance to nearest neighbor 2d for an explanation of effects of this flag.
Please refer to documentation of following measures for more information :
measure allowing to compute number of neighbors of shapes given a distance threshold
Measure synthesis :
Measure Type | Measure Unit Type | Parameter Type | Result Type | Shape Requirements |
Generic
|
None
|
NbNeighborsMsrParams |
Value (ipsdk::ipUInt32)
|
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, "NbNeighborsMsr")
outMeasureSet = shapeanalysis.labelAnalysis2d(inGreyImg, inLabelImg2d, inMeasureInfoSet2d)
PyIPSDK.saveCsvMeasureFile(os.path.join(tmpPath, "shape_analysis_results.csv"), outMeasureSet)
outMsr = outMeasureSet.getMeasure("NbNeighborsMsr")
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, "NbNeighborsMsr")
outMeasureSet = shapeanalysis.labelAnalysis3d(inGreyImg, inLabelImg, inMeasureInfoSet3d)
PyIPSDK.saveCsvMeasureFile(os.path.join(tmpPath, "shape_analysis_results.csv"), outMeasureSet)
outMsr = outMeasureSet.getMeasure("NbNeighborsMsr")
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, "NbNeighborsMsr", createNeighborsDistanceMsrParams(maxDist, bProcessHoles));
MeasureSetPtr pOutMeasureSet =
shapeAnalysis2d(pInGreyImg2d, pShape2dColl, pMeasureInfoSet);
const MeasureConstPtr& pNbNeighborsOutMsr = pOutMeasureSet->getMeasure("NbNeighborsMsr");
const ipsdk::shape::analysis::ValueMeasureResult<ipsdk::ipUInt32>& outResults = static_cast<const ipsdk::shape::analysis::ValueMeasureResult<ipsdk::ipUInt32>&>(pNbNeighborsOutMsr->getMeasureResult());