ImageDev

MarkerBasedWatershed3d

Performs a fast determination of the watershed lines in a three-dimensional grayscale image from a predefined set of markers.

Access to parameter description

For an introduction: This algorithm performs a fast determination of the watershed lines from specified markers in a label image.
It determines the crest lines separating the markers.

Three ways of presenting the resulting image are provided: Note: Because two bits are used to code the pixels during the algorithm, the input gray level image should range from 0 to 16383. If the range is greater, a normalization is applied to reduce the dynamic of this image.

See also
See related example

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > markerBasedWatershed3d( std::shared_ptr< iolink::ImageView > inputGrayImage, std::shared_ptr< iolink::ImageView > inputMarkerImage, MarkerBasedWatershed3d::AlgorithmMode algorithmMode, MarkerBasedWatershed3d::OutputType outputType, MarkerBasedWatershed3d::Neighborhood neighborhood, std::shared_ptr< iolink::ImageView > outputImage = nullptr );
This function returns outputImage.
// Function prototype.
marker_based_watershed_3d(input_gray_image: idt.ImageType,
                          input_marker_image: idt.ImageType,
                          algorithm_mode: MarkerBasedWatershed3d.AlgorithmMode = MarkerBasedWatershed3d.AlgorithmMode.REPEATABLE,
                          output_type: MarkerBasedWatershed3d.OutputType = MarkerBasedWatershed3d.OutputType.SEPARATED_REGIONS,
                          neighborhood: MarkerBasedWatershed3d.Neighborhood = MarkerBasedWatershed3d.Neighborhood.CONNECTIVITY_26,
                          output_image: idt.ImageType = None) -> idt.ImageType
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
MarkerBasedWatershed3d( IOLink.ImageView inputGrayImage,
                        IOLink.ImageView inputMarkerImage,
                        MarkerBasedWatershed3d.AlgorithmMode algorithmMode = ImageDev.MarkerBasedWatershed3d.AlgorithmMode.REPEATABLE,
                        MarkerBasedWatershed3d.OutputType outputType = ImageDev.MarkerBasedWatershed3d.OutputType.SEPARATED_REGIONS,
                        MarkerBasedWatershed3d.Neighborhood neighborhood = ImageDev.MarkerBasedWatershed3d.Neighborhood.CONNECTIVITY_26,
                        IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputGrayImage
The input grayscale image representing the landscape of the watershed. Image Grayscale nullptr
input
inputMarkerImage
The input label image of markers. Image Label nullptr
input
algorithmMode
The mode for applying the watershed algorithm.
REPEATABLE The result is repeatable but slower to compute.
FAST The result is faster to compute but not repeatable because of asynchronous parallel computation. Since a watershed problem does not generally have a unique solution, two processings of the same image can lead to two different results (both exact).
Enumeration REPEATABLE
input
outputType
The type of output image.
LINES The output is a binary image representing only the watershed lines.
CONTIGUOUS_REGIONS The output is a label image representing only the marked basins. Voxels belonging to the watershed lines are filled with the most present label of their 26 neighbors.
SEPARATED_REGIONS The output is a label image representing only the marked basins. Pixels belonging to the watershed lines are considered as background (set to 0).
Enumeration SEPARATED_REGIONS
input
neighborhood
The 3D neighborhood configuration defining the connected components.
CONNECTIVITY_6 Connected components are defined by a 6-neighbor connectivity. The connectivity pattern is composed of voxels sharing a common face with the voxel of interest.
CONNECTIVITY_18 Connected components are defined by a 18-neighbor connectivity. The connectivity pattern is composed of voxels sharing a common edge with the voxel of interest.
CONNECTIVITY_26 Connected components are defined by a 26-neighbor connectivity. The connectivity pattern is a full cube.
Enumeration CONNECTIVITY_26
output
outputImage
The output binary image. Its dimensions are forced to the same values as the input image. Its type depends on the selected outputType and potentially on the highest label of the inputMarkerImage. Image nullptr
Parameter Name Description Type Supported Values Default Value
input
input_gray_image
The input grayscale image representing the landscape of the watershed. image Grayscale None
input
input_marker_image
The input label image of markers. image Label None
input
algorithm_mode
The mode for applying the watershed algorithm.
REPEATABLE The result is repeatable but slower to compute.
FAST The result is faster to compute but not repeatable because of asynchronous parallel computation. Since a watershed problem does not generally have a unique solution, two processings of the same image can lead to two different results (both exact).
enumeration REPEATABLE
input
output_type
The type of output image.
LINES The output is a binary image representing only the watershed lines.
CONTIGUOUS_REGIONS The output is a label image representing only the marked basins. Voxels belonging to the watershed lines are filled with the most present label of their 26 neighbors.
SEPARATED_REGIONS The output is a label image representing only the marked basins. Pixels belonging to the watershed lines are considered as background (set to 0).
enumeration SEPARATED_REGIONS
input
neighborhood
The 3D neighborhood configuration defining the connected components.
CONNECTIVITY_6 Connected components are defined by a 6-neighbor connectivity. The connectivity pattern is composed of voxels sharing a common face with the voxel of interest.
CONNECTIVITY_18 Connected components are defined by a 18-neighbor connectivity. The connectivity pattern is composed of voxels sharing a common edge with the voxel of interest.
CONNECTIVITY_26 Connected components are defined by a 26-neighbor connectivity. The connectivity pattern is a full cube.
enumeration CONNECTIVITY_26
output
output_image
The output binary image. Its dimensions are forced to the same values as the input image. Its type depends on the selected outputType and potentially on the highest label of the inputMarkerImage. image None
Parameter Name Description Type Supported Values Default Value
input
inputGrayImage
The input grayscale image representing the landscape of the watershed. Image Grayscale null
input
inputMarkerImage
The input label image of markers. Image Label null
input
algorithmMode
The mode for applying the watershed algorithm.
REPEATABLE The result is repeatable but slower to compute.
FAST The result is faster to compute but not repeatable because of asynchronous parallel computation. Since a watershed problem does not generally have a unique solution, two processings of the same image can lead to two different results (both exact).
Enumeration REPEATABLE
input
outputType
The type of output image.
LINES The output is a binary image representing only the watershed lines.
CONTIGUOUS_REGIONS The output is a label image representing only the marked basins. Voxels belonging to the watershed lines are filled with the most present label of their 26 neighbors.
SEPARATED_REGIONS The output is a label image representing only the marked basins. Pixels belonging to the watershed lines are considered as background (set to 0).
Enumeration SEPARATED_REGIONS
input
neighborhood
The 3D neighborhood configuration defining the connected components.
CONNECTIVITY_6 Connected components are defined by a 6-neighbor connectivity. The connectivity pattern is composed of voxels sharing a common face with the voxel of interest.
CONNECTIVITY_18 Connected components are defined by a 18-neighbor connectivity. The connectivity pattern is composed of voxels sharing a common edge with the voxel of interest.
CONNECTIVITY_26 Connected components are defined by a 26-neighbor connectivity. The connectivity pattern is a full cube.
Enumeration CONNECTIVITY_26
output
outputImage
The output binary image. Its dimensions are forced to the same values as the input image. Its type depends on the selected outputType and potentially on the highest label of the inputMarkerImage. Image null

Object Examples

auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" );
auto foam_sep_label = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam_sep_label.vip" );

MarkerBasedWatershed3d markerBasedWatershed3dAlgo;
markerBasedWatershed3dAlgo.setInputGrayImage( foam );
markerBasedWatershed3dAlgo.setInputMarkerImage( foam_sep_label );
markerBasedWatershed3dAlgo.setAlgorithmMode( MarkerBasedWatershed3d::AlgorithmMode::REPEATABLE );
markerBasedWatershed3dAlgo.setOutputType( MarkerBasedWatershed3d::OutputType::LINES );
markerBasedWatershed3dAlgo.setNeighborhood( MarkerBasedWatershed3d::Neighborhood::CONNECTIVITY_26 );
markerBasedWatershed3dAlgo.execute();

std::cout << "outputImage:" << markerBasedWatershed3dAlgo.outputImage()->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))
foam_sep_label = imagedev.read_vip_image(imagedev_data.get_image_path("foam_sep_label.vip"))

marker_based_watershed_3d_algo = imagedev.MarkerBasedWatershed3d()
marker_based_watershed_3d_algo.input_gray_image = foam
marker_based_watershed_3d_algo.input_marker_image = foam_sep_label
marker_based_watershed_3d_algo.algorithm_mode = imagedev.MarkerBasedWatershed3d.REPEATABLE
marker_based_watershed_3d_algo.output_type = imagedev.MarkerBasedWatershed3d.LINES
marker_based_watershed_3d_algo.neighborhood = imagedev.MarkerBasedWatershed3d.CONNECTIVITY_26
marker_based_watershed_3d_algo.execute()

print("output_image:", str(marker_based_watershed_3d_algo.output_image))
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );
ImageView foam_sep_label = Data.ReadVipImage( @"Data/images/foam_sep_label.vip" );

MarkerBasedWatershed3d markerBasedWatershed3dAlgo = new MarkerBasedWatershed3d
{
    inputGrayImage = foam,
    inputMarkerImage = foam_sep_label,
    algorithmMode = MarkerBasedWatershed3d.AlgorithmMode.REPEATABLE,
    outputType = MarkerBasedWatershed3d.OutputType.LINES,
    neighborhood = MarkerBasedWatershed3d.Neighborhood.CONNECTIVITY_26
};
markerBasedWatershed3dAlgo.Execute();

Console.WriteLine( "outputImage:" + markerBasedWatershed3dAlgo.outputImage.ToString() );

Function Examples

auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" );
auto foam_sep_label = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam_sep_label.vip" );

auto result = markerBasedWatershed3d( foam, foam_sep_label, MarkerBasedWatershed3d::AlgorithmMode::REPEATABLE, MarkerBasedWatershed3d::OutputType::LINES, MarkerBasedWatershed3d::Neighborhood::CONNECTIVITY_26 );

std::cout << "outputImage:" << result->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))
foam_sep_label = imagedev.read_vip_image(imagedev_data.get_image_path("foam_sep_label.vip"))

result = imagedev.marker_based_watershed_3d(foam, foam_sep_label, imagedev.MarkerBasedWatershed3d.REPEATABLE, imagedev.MarkerBasedWatershed3d.LINES, imagedev.MarkerBasedWatershed3d.CONNECTIVITY_26)

print("output_image:", str(result))
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );
ImageView foam_sep_label = Data.ReadVipImage( @"Data/images/foam_sep_label.vip" );

IOLink.ImageView result = Processing.MarkerBasedWatershed3d( foam, foam_sep_label, MarkerBasedWatershed3d.AlgorithmMode.REPEATABLE, MarkerBasedWatershed3d.OutputType.LINES, MarkerBasedWatershed3d.Neighborhood.CONNECTIVITY_26 );

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