ImageDev

DijkstraShortestPath2d

Finds the shortest path through an image, considering the image intensities as weights.

Access to parameter description

This algorithm is used to find the shortest path through an image using local maxima or minima and represent it in a binary image.

The path can be searched either from the left to the right side (X axis mode), or from the top to the bottom (Y axis mode) of the input image.
In dark intensity mode the path must minimize the sum of the traveled intensities, while in bright mode it must maximize this sum.
A binary input image has to be set to guide the path inside this mask.

See also

Function Syntax

This function returns outputBinaryImage.
// Function prototype
std::shared_ptr< iolink::ImageView > dijkstraShortestPath2d( std::shared_ptr< iolink::ImageView > inputGrayImage, std::shared_ptr< iolink::ImageView > inputMaskImage, DijkstraShortestPath2d::Axis axis, DijkstraShortestPath2d::IntensityMode intensityMode, std::shared_ptr< iolink::ImageView > outputBinaryImage = NULL );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputGrayImage
The grayscale input image. Image Binary, Label or Grayscale nullptr
input
inputMaskImage
The binary input image for the mask. Image Binary nullptr
input
axis
The direction of the searched path.
X_AXIS The shortest path is searched through the X axis.
Y_AXIS The shortest path is searched through the Y axis.

Enumeration X_AXIS
input
intensityMode
The type of enclosed objects.
BRIGHT The shortest path is searched through the intensity maxima pixels.
DARK The shortest path is searched through the intensity minima pixels.
Enumeration BRIGHT
output
outputBinaryImage
The binary output image. Image nullptr

Object Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );
auto polystyrene_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep.vip" );

DijkstraShortestPath2d dijkstraShortestPath2dAlgo;
dijkstraShortestPath2dAlgo.setInputGrayImage( polystyrene );
dijkstraShortestPath2dAlgo.setInputMaskImage( polystyrene_sep );
dijkstraShortestPath2dAlgo.setAxis( DijkstraShortestPath2d::Axis::X_AXIS );
dijkstraShortestPath2dAlgo.setIntensityMode( DijkstraShortestPath2d::IntensityMode::BRIGHT );
dijkstraShortestPath2dAlgo.execute();

std::cout << "outputBinaryImage:" << dijkstraShortestPath2dAlgo.outputBinaryImage()->toString();

Function Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );
auto polystyrene_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep.vip" );

auto result = dijkstraShortestPath2d( polystyrene, polystyrene_sep, DijkstraShortestPath2d::Axis::X_AXIS, DijkstraShortestPath2d::IntensityMode::BRIGHT );

std::cout << "outputBinaryImage:" << result->toString();