measure the roughness
Roughness measure needs, among other input parameters, the maximum distance between 2 points for the polygon approximation. This allows to extract another polygon approximation
from the shape
and computes its perimeter
. The roughness
is simply the ratio between those perimeters:
Where
is the perimeter of the input shape
and
is the perimeter of the second polygon approximation
using the measure input parameter PolygApproxMaxDist.
We note that
and increases when the difference between
and
increases.
The following figure illustrates a concave shape with two polygon approximations. The blue polygon has a maximum distance polygon approximation of 1.5 (its default value) and the green one has an approximation of 10:
Here is an example of roughness measurement, with "consider holes" parameter set to 'true'and the maximum distance polygon approximation set to 10:
measure the roughness
Measure synthesis :
Measure Type | Measure Unit Type | Parameter Type | Result Type | Shape Requirements |
Geometry 2d
|
None
|
Roughness2dMsrParams |
Value (ipsdk::ipReal64)
|
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, "Roughness2dMsr")
outMeasureSet = shapeanalysis.labelAnalysis2d(inGreyImg, inLabelImg2d, inMeasureInfoSet2d)
PyIPSDK.saveCsvMeasureFile(os.path.join(tmpPath, "shape_analysis_results.csv"), outMeasureSet)
outMsr = outMeasureSet.getMeasure("Roughness2dMsr")
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);
const ipBool bProcessHoles = true;
const ipReal64 maxDist = 10.;
MeasureInfoSetPtr pMeasureInfoSet = MeasureInfoSet::create2dInstance();
createMeasureInfo(pMeasureInfoSet, "Roughness2dMsr", createRoughness2dMsrParams(bProcessHoles, maxDist));
MeasureSetPtr pOutMeasureSet =
shapeAnalysis2d(pInGreyImg2d, pShape2dColl, pMeasureInfoSet);
const MeasureConstPtr& pRoughness2dOutMsr = pOutMeasureSet->getMeasure("Roughness2dMsr");
const ipsdk::shape::analysis::ValueMeasureResult<ipsdk::ipReal64>& outResults = static_cast<const ipsdk::shape::analysis::ValueMeasureResult<ipsdk::ipReal64>&>(pRoughness2dOutMsr->getMeasureResult());