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 = nullptr );
This function returns outputBinaryImage.
// Function prototype.
dijkstra_shortest_path_2d(input_gray_image: idt.ImageType,
                          input_mask_image: idt.ImageType,
                          axis: DijkstraShortestPath2d.Axis = DijkstraShortestPath2d.Axis.X_AXIS,
                          intensity_mode: DijkstraShortestPath2d.IntensityMode = DijkstraShortestPath2d.IntensityMode.BRIGHT,
                          output_binary_image: idt.ImageType = None) -> idt.ImageType
This function returns outputBinaryImage.
// Function prototype.
public static IOLink.ImageView
DijkstraShortestPath2d( IOLink.ImageView inputGrayImage,
                        IOLink.ImageView inputMaskImage,
                        DijkstraShortestPath2d.Axis axis = ImageDev.DijkstraShortestPath2d.Axis.X_AXIS,
                        DijkstraShortestPath2d.IntensityMode intensityMode = ImageDev.DijkstraShortestPath2d.IntensityMode.BRIGHT,
                        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
Parameter Name Description Type Supported Values Default Value
input
input_gray_image
The grayscale input image. image Binary, Label or Grayscale None
input
input_mask_image
The binary input image for the mask. image Binary None
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
intensity_mode
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
output_binary_image
The binary output image. image None
Parameter Name Description Type Supported Values Default Value
input
inputGrayImage
The grayscale input image. Image Binary, Label or Grayscale null
input
inputMaskImage
The binary input image for the mask. Image Binary null
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 null

Object Examples

auto 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();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))
polystyrene_sep = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep.vip"))

dijkstra_shortest_path_2d_algo = imagedev.DijkstraShortestPath2d()
dijkstra_shortest_path_2d_algo.input_gray_image = polystyrene
dijkstra_shortest_path_2d_algo.input_mask_image = polystyrene_sep
dijkstra_shortest_path_2d_algo.axis = imagedev.DijkstraShortestPath2d.X_AXIS
dijkstra_shortest_path_2d_algo.intensity_mode = imagedev.DijkstraShortestPath2d.BRIGHT
dijkstra_shortest_path_2d_algo.execute()

print("output_binary_image:", str(dijkstra_shortest_path_2d_algo.output_binary_image))
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );
ImageView polystyrene_sep = Data.ReadVipImage( @"Data/images/polystyrene_sep.vip" );

DijkstraShortestPath2d dijkstraShortestPath2dAlgo = new DijkstraShortestPath2d
{
    inputGrayImage = polystyrene,
    inputMaskImage = polystyrene_sep,
    axis = DijkstraShortestPath2d.Axis.X_AXIS,
    intensityMode = DijkstraShortestPath2d.IntensityMode.BRIGHT
};
dijkstraShortestPath2dAlgo.Execute();

Console.WriteLine( "outputBinaryImage:" + dijkstraShortestPath2dAlgo.outputBinaryImage.ToString() );

Function Examples

auto 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();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))
polystyrene_sep = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep.vip"))

result = imagedev.dijkstra_shortest_path_2d(polystyrene, polystyrene_sep, imagedev.DijkstraShortestPath2d.X_AXIS, imagedev.DijkstraShortestPath2d.BRIGHT)

print("output_binary_image:", str(result))
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );
ImageView polystyrene_sep = Data.ReadVipImage( @"Data/images/polystyrene_sep.vip" );

IOLink.ImageView result = Processing.DijkstraShortestPath2d( polystyrene, polystyrene_sep, DijkstraShortestPath2d.Axis.X_AXIS, DijkstraShortestPath2d.IntensityMode.BRIGHT );

Console.WriteLine( "outputBinaryImage:" + result.ToString() );