ImageDev

MarkerBasedWatershedByBlock

Performs a fast determination of the watershed lines in a grayscale image from a predefined set of markers in a low memory consumption mode.

Access to parameter description

For an introduction: This algorithm is equivalent to the MarkerBasedWatershed algorithm, but uses a totally different strategy in order to require less memory.

It is based on a block-wise implementation of the watershed algorithm, building a graph allowing the propagation of the catchment areas through the entire image.

Note:
See also

Function Syntax

This function returns the outputBinaryImage output parameter.
// Function prototype.
std::shared_ptr< iolink::ImageView >
markerBasedWatershedByBlock( std::shared_ptr< iolink::ImageView > inputGrayImage,
                             std::shared_ptr< iolink::ImageView > inputMarkerImage,
                             MarkerBasedWatershedByBlock::AlgorithmMode algorithmMode,
                             int32_t blockSize,
                             std::shared_ptr< iolink::ImageView > outputBinaryImage = NULL );
This function returns the outputBinaryImage output parameter.
// Function prototype.
marker_based_watershed_by_block( input_gray_image,
                                 input_marker_image,
                                 algorithm_mode = MarkerBasedWatershedByBlock.AlgorithmMode.REPEATABLE,
                                 block_size = 256,
                                 output_binary_image = None )
This function returns the outputBinaryImage output parameter.
// Function prototype.
public static IOLink.ImageView
MarkerBasedWatershedByBlock( IOLink.ImageView inputGrayImage,
                             IOLink.ImageView inputMarkerImage,
                             MarkerBasedWatershedByBlock.AlgorithmMode algorithmMode = ImageDev.MarkerBasedWatershedByBlock.AlgorithmMode.REPEATABLE,
                             Int32 blockSize = 256,
                             IOLink.ImageView outputBinaryImage = null );

Class Syntax

Parameters

Class Name MarkerBasedWatershedByBlock

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
blockSize
The size of blocks used to crop the input images. Int32 >=32 256
output
outputBinaryImage
The output binary image. Its dimensions are forced to the same values as the input image. Image nullptr

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" );

MarkerBasedWatershedByBlock markerBasedWatershedByBlockAlgo;
markerBasedWatershedByBlockAlgo.setInputGrayImage( foam );
markerBasedWatershedByBlockAlgo.setInputMarkerImage( foam_sep_label );
markerBasedWatershedByBlockAlgo.setAlgorithmMode( MarkerBasedWatershedByBlock::AlgorithmMode::REPEATABLE );
markerBasedWatershedByBlockAlgo.setBlockSize( 256 );
markerBasedWatershedByBlockAlgo.execute();

std::cout << "outputBinaryImage:" << markerBasedWatershedByBlockAlgo.outputBinaryImage()->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_by_block_algo = imagedev.MarkerBasedWatershedByBlock()
marker_based_watershed_by_block_algo.input_gray_image = foam
marker_based_watershed_by_block_algo.input_marker_image = foam_sep_label
marker_based_watershed_by_block_algo.algorithm_mode = imagedev.MarkerBasedWatershedByBlock.REPEATABLE
marker_based_watershed_by_block_algo.block_size = 256
marker_based_watershed_by_block_algo.execute()

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

MarkerBasedWatershedByBlock markerBasedWatershedByBlockAlgo = new MarkerBasedWatershedByBlock
{
    inputGrayImage = foam,
    inputMarkerImage = foam_sep_label,
    algorithmMode = MarkerBasedWatershedByBlock.AlgorithmMode.REPEATABLE,
    blockSize = 256
};
markerBasedWatershedByBlockAlgo.Execute();

Console.WriteLine( "outputBinaryImage:" + markerBasedWatershedByBlockAlgo.outputBinaryImage.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 = markerBasedWatershedByBlock( foam, foam_sep_label, MarkerBasedWatershedByBlock::AlgorithmMode::REPEATABLE, 256 );

std::cout << "outputBinaryImage:" << 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_by_block( foam, foam_sep_label, imagedev.MarkerBasedWatershedByBlock.REPEATABLE, 256 )

print( "output_binary_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.MarkerBasedWatershedByBlock( foam, foam_sep_label, MarkerBasedWatershedByBlock.AlgorithmMode.REPEATABLE, 256 );

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