ImageDev

MarkerBasedWatershedBasinsByBlock

Performs a fast determination of the catchment basins 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.

Notices:
See also

Function Syntax

This function returns outputLabelImage.
// Function prototype
std::shared_ptr< iolink::ImageView > markerBasedWatershedBasinsByBlock( std::shared_ptr< iolink::ImageView > inputGrayImage, std::shared_ptr< iolink::ImageView > inputMarkerImage, MarkerBasedWatershedBasinsByBlock::AlgorithmMode algorithmMode, int32_t blockSize, std::shared_ptr< iolink::ImageView > outputLabelImage = NULL );
This function returns outputLabelImage.
// Function prototype.
marker_based_watershed_basins_by_block( input_gray_image,
                                        input_marker_image,
                                        algorithm_mode = MarkerBasedWatershedBasinsByBlock.AlgorithmMode.REPEATABLE,
                                        block_size = 256,
                                        output_label_image = None )
This function returns outputLabelImage.
// Function prototype.
public static IOLink.ImageView
MarkerBasedWatershedBasinsByBlock( IOLink.ImageView inputGrayImage,
                                   IOLink.ImageView inputMarkerImage,
                                   MarkerBasedWatershedBasinsByBlock.AlgorithmMode algorithmMode = ImageDev.MarkerBasedWatershedBasinsByBlock.AlgorithmMode.REPEATABLE,
                                   Int32 blockSize = 256,
                                   IOLink.ImageView outputLabelImage = null );

Class Syntax

Parameters

Class Name MarkerBasedWatershedBasinsByBlock

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
outputLabelImage
The output label image of basins. 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" );

MarkerBasedWatershedBasinsByBlock markerBasedWatershedBasinsByBlockAlgo;
markerBasedWatershedBasinsByBlockAlgo.setInputGrayImage( foam );
markerBasedWatershedBasinsByBlockAlgo.setInputMarkerImage( foam_sep_label );
markerBasedWatershedBasinsByBlockAlgo.setAlgorithmMode( MarkerBasedWatershedBasinsByBlock::AlgorithmMode::REPEATABLE );
markerBasedWatershedBasinsByBlockAlgo.setBlockSize( 256 );
markerBasedWatershedBasinsByBlockAlgo.execute();

std::cout << "outputLabelImage:" << markerBasedWatershedBasinsByBlockAlgo.outputLabelImage()->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_basins_by_block_algo = imagedev.MarkerBasedWatershedBasinsByBlock()
marker_based_watershed_basins_by_block_algo.input_gray_image = foam
marker_based_watershed_basins_by_block_algo.input_marker_image = foam_sep_label
marker_based_watershed_basins_by_block_algo.algorithm_mode = imagedev.MarkerBasedWatershedBasinsByBlock.REPEATABLE
marker_based_watershed_basins_by_block_algo.block_size = 256
marker_based_watershed_basins_by_block_algo.execute()

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

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

Console.WriteLine( "outputLabelImage:" + markerBasedWatershedBasinsByBlockAlgo.outputLabelImage.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 = markerBasedWatershedBasinsByBlock( foam, foam_sep_label, MarkerBasedWatershedBasinsByBlock::AlgorithmMode::REPEATABLE, 256 );

std::cout << "outputLabelImage:" << 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_basins_by_block( foam, foam_sep_label, imagedev.MarkerBasedWatershedBasinsByBlock.REPEATABLE, 256 )

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

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