IPSDK 0.2
IPSDK : Image Processing Software Development Kit

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 $A$ from the shape $S$ and computes its perimeter $p_A$. The roughness $R$ is simply the ratio between those perimeters:

\[ R = \frac{\max \left( p_S, p_A \right)}{\min \left( p_S, p_A \right)} \]

Where $p_S$ is the perimeter of the input shape $S$ and $p_A$ is the perimeter of the second polygon approximation $A$ using the measure input parameter PolygApproxMaxDist.

We note that $R \geq 1 $ and increases when the difference between $p_S$ and $p_A$ 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:

roughness2dMsrIllustration.png

Here is an example of roughness measurement, with "consider holes" parameter set to 'true'and the maximum distance polygon approximation set to 10:

roughness2dMsr.png

measure the roughness

Measure synthesis :

Measure Type Measure Unit Type Parameter Type Result Type Shape Requirements
Geometry2d.png
Geometry 2d
none.png
None
parameter.png
Roughness2dMsrParams
Value.png
Value (ipsdk::ipReal64)
BoundaryApproximation.png
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
# Create the infoset
inMeasureInfoSet2d = PyIPSDK.createMeasureInfoSet2d()
PyIPSDK.createMeasureInfo(inMeasureInfoSet2d, "Roughness2dMsr")
#Perform the analysis
outMeasureSet = shapeanalysis.labelAnalysis2d(inGreyImg, inLabelImg2d, inMeasureInfoSet2d)
# save results to csv format
PyIPSDK.saveCsvMeasureFile(os.path.join(tmpPath, "shape_analysis_results.csv"), outMeasureSet)
# retrieve measure results
outMsr = outMeasureSet.getMeasure("Roughness2dMsr")
# retrieve measure values
outMsrValues = outMsr.getMeasureResult().getColl(0)
print("First label measurement equal " + str(outMsrValues[1]))

Example of C++ code :

Example informations

Associated library

IPSDKIPLShapeAnalysis

Code Example

// opening grey level input image
ImagePtr pInGreyImg2d = loadTiffImageFile(inputGreyImgPath);
// read entity shape 2d collection used for processing
Shape2dCollPtr pShape2dColl = boost::make_shared<Shape2dColl>();
IPSDK_REQUIRE(readFromXmlFile(inputShape2dCollPath, *pShape2dColl) == true);
// define a measure info set
const ipBool bProcessHoles = true;
const ipReal64 maxDist = 10.;
MeasureInfoSetPtr pMeasureInfoSet = MeasureInfoSet::create2dInstance();
createMeasureInfo(pMeasureInfoSet, "Roughness2dMsr", createRoughness2dMsrParams(bProcessHoles, maxDist));
// compute measure on shape 2d collection
MeasureSetPtr pOutMeasureSet = shapeAnalysis2d(pInGreyImg2d, pShape2dColl, pMeasureInfoSet);
// retrieve associated results
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());