IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

Computes the shortest path from one border to its opposite, given distance ponderation map. More...

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::RidgeLine2dResult ipsdk::imaproc::advmorpho::ridgeLine2dImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::ePropagationAxis &pInPropagationAxis, const ipsdk::imaproc::attr::ePropagationDirection &pInPropagationDirection)
 wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map. More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::RidgeLine2dResult ipsdk::imaproc::advmorpho::ridgeLine2dImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::image::ImageConstPtr &pInOptMaskImg, const ipsdk::imaproc::attr::ePropagationAxis &pInPropagationAxis, const ipsdk::imaproc::attr::ePropagationDirection &pInPropagationDirection)
 wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map. More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::RidgeLine2dResult ipsdk::imaproc::advmorpho::ridgeLine2dImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::ePropagationAxis &pInPropagationAxis, const ipsdk::imaproc::attr::ePropagationDirection &pInPropagationDirection, const ipsdk::ipUInt32 nbIter)
 wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map. More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::RidgeLine2dResult ipsdk::imaproc::advmorpho::ridgeLine2dImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::image::ImageConstPtr &pInOptMaskImg, const ipsdk::imaproc::attr::ePropagationAxis &pInPropagationAxis, const ipsdk::imaproc::attr::ePropagationDirection &pInPropagationDirection, const ipsdk::ipUInt32 nbIter)
 wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map. More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::Pixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::ePropagationAxis &pInPropagationAxis, const ipsdk::imaproc::attr::ePropagationDirection &pInPropagationDirection, const ipsdk::image::ImagePtr &pOutShortestPathImg, const ipsdk::image::ImagePtr &pOutDistanceMap, const ipsdk::image::ImagePtr &pOutPathMap)
 wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map. More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::Pixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::image::ImageConstPtr &pInOptMaskImg, const ipsdk::imaproc::attr::ePropagationAxis &pInPropagationAxis, const ipsdk::imaproc::attr::ePropagationDirection &pInPropagationDirection, const ipsdk::image::ImagePtr &pOutShortestPathImg, const ipsdk::image::ImagePtr &pOutDistanceMap, const ipsdk::image::ImagePtr &pOutPathMap)
 wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map. More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::Pixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::ePropagationAxis &pInPropagationAxis, const ipsdk::imaproc::attr::ePropagationDirection &pInPropagationDirection, const ipsdk::ipUInt32 nbIter, const ipsdk::image::ImagePtr &pOutShortestPathImg, const ipsdk::image::ImagePtr &pOutDistanceMap, const ipsdk::image::ImagePtr &pOutPathMap)
 wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map. More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::Pixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::image::ImageConstPtr &pInOptMaskImg, const ipsdk::imaproc::attr::ePropagationAxis &pInPropagationAxis, const ipsdk::imaproc::attr::ePropagationDirection &pInPropagationDirection, const ipsdk::ipUInt32 nbIter, const ipsdk::image::ImagePtr &pOutShortestPathImg, const ipsdk::image::ImagePtr &pOutDistanceMap, const ipsdk::image::ImagePtr &pOutPathMap)
 wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map. More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::PlanIndexedPixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg_multiSlice (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::ePropagationAxis &pInPropagationAxis, const ipsdk::imaproc::attr::ePropagationDirection &pInPropagationDirection, const ipsdk::image::ImagePtr &pOutShortestPathImg, const ipsdk::image::ImagePtr &pOutDistanceMap, const ipsdk::image::ImagePtr &pOutPathMap)
 wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map. More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::PlanIndexedPixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg_multiSlice (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::image::ImageConstPtr &pInOptMaskImg, const ipsdk::imaproc::attr::ePropagationAxis &pInPropagationAxis, const ipsdk::imaproc::attr::ePropagationDirection &pInPropagationDirection, const ipsdk::image::ImagePtr &pOutShortestPathImg, const ipsdk::image::ImagePtr &pOutDistanceMap, const ipsdk::image::ImagePtr &pOutPathMap)
 wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map. More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::PlanIndexedPixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg_multiSlice (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::ePropagationAxis &pInPropagationAxis, const ipsdk::imaproc::attr::ePropagationDirection &pInPropagationDirection, const ipsdk::ipUInt32 nbIter, const ipsdk::image::ImagePtr &pOutShortestPathImg, const ipsdk::image::ImagePtr &pOutDistanceMap, const ipsdk::image::ImagePtr &pOutPathMap)
 wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map. More...
 
IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::PlanIndexedPixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg_multiSlice (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::image::ImageConstPtr &pInOptMaskImg, const ipsdk::imaproc::attr::ePropagationAxis &pInPropagationAxis, const ipsdk::imaproc::attr::ePropagationDirection &pInPropagationDirection, const ipsdk::ipUInt32 nbIter, const ipsdk::image::ImagePtr &pOutShortestPathImg, const ipsdk::image::ImagePtr &pOutDistanceMap, const ipsdk::image::ImagePtr &pOutPathMap)
 wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map. More...
 

Detailed Description

Computes the shortest path from one border to its opposite, given distance ponderation map.

The 2D ridge line algorithm allows to compute the shortest path to cross an image along the x or y axis. It is also possible to specify the propagation direction. This direction can be direct (from left to right or from top to bottom) or reverse (from right to left or from bottom to top).

The distance, to reach a pixel, between one of its 8-neighbors is given by its intensity. More the intensity will be high, more the access to the pixel will be unfavourable. This means that the algorithm tries to find a path through the darkest pixels.

This algorithm returns :

The calculation time can be drastically reduced by specifying a number of iterations. If this parameter is higher than 0, the algorithm will stop before converging to the final result. Although the result will be an approximation of the shortest path, it will stay close to the eact result.

Finally, it is possible to specify a propagation area by passing an additional mask as parameter.

Here is an example of the ridge line algorithm output :

ridgeLine2dImg_example.png

In that particular case we can find two interesting paths. One at the middle of the image and one at the bottom. Within the previous figure the shortest path is the interface between the background and the object. It's possible to get the interface between the two materials by using a mask restricting the propagation to the bottom of the image.

Here is a mask use case :

ridgeLine2dImg_exampleMask.png

The distance for each pixel of the shortest path is given by the intensity field of the Pixel2d data item. It is also possible to obtain the shortest path length for slice (z, c, t) thanks to the function computeShortestPathLength.

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg [Input] image for processing operation X
ipsdk::imaproc::attr::InOptMaskImg [Input Optional] Binary image for masking operation X
ipsdk::imaproc::attr::InPropagationAxis [Input] input axis propagation for the algorithm X
ipsdk::imaproc::attr::InPropagationDirection [Input] Direction propagation for the algorithm X
ipsdk::imaproc::attr::InOptComputeOutImg [Input Optional] Flag indicating if the optional output image has to be computed X
ipsdk::imaproc::attr::InNbIter [Input] Number of iterations for an iterative algorithm X
ipsdk::imaproc::attr::OutDistImg [Output] distance map image duplicateInOut (_pOutDistImg, _pInImg, ipsdk::image::eImageBufferType::eIBT_Real32)
ipsdk::imaproc::attr::OutIntImg [Output] image containing integers duplicateInOut (_pOutIntImg, _pInImg, ipsdk::image::eImageBufferType::eIBT_UInt8)
ipsdk::imaproc::attr::OutBinImg [Output] binary image for processing operation duplicateInOut (_pOutBinImg, _pInImg, ipsdk::image::eImageBufferType::eIBT_Binary)
ipsdk::imaproc::attr::OutPIPixels2d [Output] plan indexed collection of positions and intensities of 2d pixels ipsdk::imaproc::fromImage (_pOutPIPixels2d, _pInImg)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchSize (_pInImg,_pOutDistImg,_pOutIntImg) && 
ipsdk::imaproc::matchImagePlans (_pOutPIPixels2d,_pInImg,eImagePlansMatchPolicy::eIPMP_ZCT) && 
ipsdk::processor::If (
 ipsdk::processor::isSet (_pInOptMaskImg),
 ipsdk::imaproc::matchSize (_pInImg,_pInOptMaskImg),
 ipsdk::processor::none ()) && 
ipsdk::imaproc::matchSize (_pOutDistImg,_pOutBinImg)

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLAdvancedMorphology as advmorpho

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# opening of input mask
inOptMaskImg = PyIPSDK.loadTiffImageFile(inputOptMaskPath)
# Ridge Line 2d computation
outShortestPathImg, outPlanIndexedPixels = advmorpho.ridgeLine2dImg(inImg, inOptMaskImg, PyIPSDK.ePropagationAxis.ePA_X, PyIPSDK.ePropagationDirection.ePD_Direct)
firstShortestPath = PyIPSDK.toPyDict(outPlanIndexedPixels)[(0, 0, 0)]
print("First shortest path", firstShortestPath)

Example of C++ code :

Example informations

Associated library

IPSDKIPLAdvancedMorphology

Header file

#include <IPSDKIPL/IPSDKIPLAdvancedMorphology/Processor/RidgeLine2dImg/RidgeLine2dImgInitPassLvl3.h>
#include <IPSDKIPL/IPSDKIPLAdvancedMorphology/Processor/RidgeLine2dImg/RidgeLine2dImgDirectPassLvl3.h>
#include <IPSDKIPL/IPSDKIPLAdvancedMorphology/Processor/RidgeLine2dImg/RidgeLine2dImgReversePassLvl3.h>

Code Example

// opening input image
ImagePtr pInImg = loadTiffImageFile(inputImgPath);
// opening optional mask image
ImagePtr pOptMaskImg = loadTiffImageFile(inputOptMaskPath);
// compute distance map on input image without mask
// compute distance map on input image with mask
RidgeLine2dResult rl2d_res_withMask = ridgeLine2dImg(pInImg, pOptMaskImg, ePropagationAxis::ePA_X, ePropagationDirection::ePD_Direct);
// retrieve computed image and the list of pixels
const ImagePtr pShortestPathImg = rl2d_res._pShortestPath;
const PlanIndexedPixels2dPtr pShortestPathList = rl2d_res._pShortestPathList;
// computes the length of the shortest path
ipReal64 lengthShortestPath = computeShortestPathLength(pShortestPathList, 0, 0, 0);
See also
RidgeLine2dImgLvl1
RidgeLine2dImgLvl2

Function Documentation

◆ ridgeLine2dImg() [1/8]

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::RidgeLine2dResult ipsdk::imaproc::advmorpho::ridgeLine2dImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::imaproc::attr::ePropagationAxis pInPropagationAxis,
const ipsdk::imaproc::attr::ePropagationDirection pInPropagationDirection 
)

wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ ridgeLine2dImg() [2/8]

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::RidgeLine2dResult ipsdk::imaproc::advmorpho::ridgeLine2dImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::image::ImageConstPtr pInOptMaskImg,
const ipsdk::imaproc::attr::ePropagationAxis pInPropagationAxis,
const ipsdk::imaproc::attr::ePropagationDirection pInPropagationDirection 
)

wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ ridgeLine2dImg() [3/8]

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::RidgeLine2dResult ipsdk::imaproc::advmorpho::ridgeLine2dImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::imaproc::attr::ePropagationAxis pInPropagationAxis,
const ipsdk::imaproc::attr::ePropagationDirection pInPropagationDirection,
const ipsdk::ipUInt32  nbIter 
)

wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ ridgeLine2dImg() [4/8]

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::RidgeLine2dResult ipsdk::imaproc::advmorpho::ridgeLine2dImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::image::ImageConstPtr pInOptMaskImg,
const ipsdk::imaproc::attr::ePropagationAxis pInPropagationAxis,
const ipsdk::imaproc::attr::ePropagationDirection pInPropagationDirection,
const ipsdk::ipUInt32  nbIter 
)

wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ ridgeLine2dImg() [5/8]

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::Pixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::imaproc::attr::ePropagationAxis pInPropagationAxis,
const ipsdk::imaproc::attr::ePropagationDirection pInPropagationDirection,
const ipsdk::image::ImagePtr pOutShortestPathImg,
const ipsdk::image::ImagePtr pOutDistanceMap,
const ipsdk::image::ImagePtr pOutPathMap 
)

wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ ridgeLine2dImg() [6/8]

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::Pixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::image::ImageConstPtr pInOptMaskImg,
const ipsdk::imaproc::attr::ePropagationAxis pInPropagationAxis,
const ipsdk::imaproc::attr::ePropagationDirection pInPropagationDirection,
const ipsdk::image::ImagePtr pOutShortestPathImg,
const ipsdk::image::ImagePtr pOutDistanceMap,
const ipsdk::image::ImagePtr pOutPathMap 
)

wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ ridgeLine2dImg() [7/8]

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::Pixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::imaproc::attr::ePropagationAxis pInPropagationAxis,
const ipsdk::imaproc::attr::ePropagationDirection pInPropagationDirection,
const ipsdk::ipUInt32  nbIter,
const ipsdk::image::ImagePtr pOutShortestPathImg,
const ipsdk::image::ImagePtr pOutDistanceMap,
const ipsdk::image::ImagePtr pOutPathMap 
)

wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ ridgeLine2dImg() [8/8]

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::Pixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::image::ImageConstPtr pInOptMaskImg,
const ipsdk::imaproc::attr::ePropagationAxis pInPropagationAxis,
const ipsdk::imaproc::attr::ePropagationDirection pInPropagationDirection,
const ipsdk::ipUInt32  nbIter,
const ipsdk::image::ImagePtr pOutShortestPathImg,
const ipsdk::image::ImagePtr pOutDistanceMap,
const ipsdk::image::ImagePtr pOutPathMap 
)

wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ ridgeLine2dImg_multiSlice() [1/4]

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::PlanIndexedPixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg_multiSlice ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::imaproc::attr::ePropagationAxis pInPropagationAxis,
const ipsdk::imaproc::attr::ePropagationDirection pInPropagationDirection,
const ipsdk::image::ImagePtr pOutShortestPathImg,
const ipsdk::image::ImagePtr pOutDistanceMap,
const ipsdk::image::ImagePtr pOutPathMap 
)

wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ ridgeLine2dImg_multiSlice() [2/4]

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::PlanIndexedPixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg_multiSlice ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::image::ImageConstPtr pInOptMaskImg,
const ipsdk::imaproc::attr::ePropagationAxis pInPropagationAxis,
const ipsdk::imaproc::attr::ePropagationDirection pInPropagationDirection,
const ipsdk::image::ImagePtr pOutShortestPathImg,
const ipsdk::image::ImagePtr pOutDistanceMap,
const ipsdk::image::ImagePtr pOutPathMap 
)

wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ ridgeLine2dImg_multiSlice() [3/4]

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::PlanIndexedPixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg_multiSlice ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::imaproc::attr::ePropagationAxis pInPropagationAxis,
const ipsdk::imaproc::attr::ePropagationDirection pInPropagationDirection,
const ipsdk::ipUInt32  nbIter,
const ipsdk::image::ImagePtr pOutShortestPathImg,
const ipsdk::image::ImagePtr pOutDistanceMap,
const ipsdk::image::ImagePtr pOutPathMap 
)

wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ ridgeLine2dImg_multiSlice() [4/4]

IPSDKIPLADVANCEDMORPHOLOGY_API ipsdk::imaproc::attr::PlanIndexedPixels2dPtr ipsdk::imaproc::advmorpho::ridgeLine2dImg_multiSlice ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::image::ImageConstPtr pInOptMaskImg,
const ipsdk::imaproc::attr::ePropagationAxis pInPropagationAxis,
const ipsdk::imaproc::attr::ePropagationDirection pInPropagationDirection,
const ipsdk::ipUInt32  nbIter,
const ipsdk::image::ImagePtr pOutShortestPathImg,
const ipsdk::image::ImagePtr pOutDistanceMap,
const ipsdk::image::ImagePtr pOutPathMap 
)

wrapper function for Computes the shortest path from one border to its opposite, given distance ponderation map.

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure