HExtremaWatershedByBlock
Computes the watershed lines of a grayscale image in a low memory consumption mode.
Access to parameter description
For an introduction:
It is based on a block-wise implementation of the watershed algorithm, building a graph allowing the propagation of the catchments areas through the entire image.
Note:
Access to parameter description
For an introduction:
- section Introduction To Watershed
- section Geodesic Transformations
It is based on a block-wise implementation of the watershed algorithm, building a graph allowing the propagation of the catchments areas through the entire image.
Note:
- This algorithm requires less free memory than the HExtremaWatershed algorithm but is much slower to execute.
- As the implementation is totally different, the results of both algorithms may differ slightly, especially on areas where the input landscape image contains some plateaus.
Function Syntax
This function returns the outputImage output parameter.
// Function prototype. std::shared_ptr< iolink::ImageView > hExtremaWatershedByBlock( std::shared_ptr< iolink::ImageView > inputGrayImage, HExtremaWatershedByBlock::ObjectLightness objectLightness, int32_t contrastValue, HExtremaWatershedByBlock::OutputType outputType, HExtremaWatershedByBlock::AlgorithmMode algorithmMode, int32_t blockSize, HExtremaWatershedByBlock::Neighborhood neighborhood, std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns the outputImage output parameter.
// Function prototype. h_extrema_watershed_by_block( input_gray_image, object_lightness = HExtremaWatershedByBlock.ObjectLightness.DARK_OBJECTS, contrast_value = 30, output_type = HExtremaWatershedByBlock.OutputType.SEPARATED_OBJECTS, algorithm_mode = HExtremaWatershedByBlock.AlgorithmMode.REPEATABLE, block_size = 256, neighborhood = HExtremaWatershedByBlock.Neighborhood.CONNECTIVITY_26, output_image = None )
This function returns the outputImage output parameter.
// Function prototype. public static IOLink.ImageView HExtremaWatershedByBlock( IOLink.ImageView inputGrayImage, HExtremaWatershedByBlock.ObjectLightness objectLightness = ImageDev.HExtremaWatershedByBlock.ObjectLightness.DARK_OBJECTS, Int32 contrastValue = 30, HExtremaWatershedByBlock.OutputType outputType = ImageDev.HExtremaWatershedByBlock.OutputType.SEPARATED_OBJECTS, HExtremaWatershedByBlock.AlgorithmMode algorithmMode = ImageDev.HExtremaWatershedByBlock.AlgorithmMode.REPEATABLE, Int32 blockSize = 256, HExtremaWatershedByBlock.Neighborhood neighborhood = ImageDev.HExtremaWatershedByBlock.Neighborhood.CONNECTIVITY_26, IOLink.ImageView outputImage = null );
Class Syntax
Parameters
Class Name | HExtremaWatershedByBlock |
---|
Parameter Name | Description | Type | Supported Values | Default Value | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
inputGrayImage |
The input grayscale image. | Image | Grayscale | nullptr | |||||||||
objectLightness |
The lightness of objects to separate.
|
Enumeration | DARK_OBJECTS | ||||||||||
contrastValue |
The depth of the valley used to select the markers of the watershed. | Int32 | >=0 | 30 | |||||||||
outputType |
The type of result image.
|
Enumeration | SEPARATED_OBJECTS | ||||||||||
algorithmMode |
The mode for applying the watershed algorithm.
|
Enumeration | REPEATABLE | ||||||||||
blockSize |
The size of blocks used to crop the input images. | Int32 | >=32 | 256 | |||||||||
neighborhood |
The 3D neighborhood configuration. This parameter is ignored with a 2D input image.
|
Enumeration | CONNECTIVITY_26 | ||||||||||
outputImage |
The output grayscale, binary or label image. Its dimensions are forced to the same values as the input image. Its type depends on the outputType parameter. | Image | nullptr |
Object Examples
auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" ); HExtremaWatershedByBlock hExtremaWatershedByBlockAlgo; hExtremaWatershedByBlockAlgo.setInputGrayImage( foam ); hExtremaWatershedByBlockAlgo.setObjectLightness( HExtremaWatershedByBlock::ObjectLightness::DARK_OBJECTS ); hExtremaWatershedByBlockAlgo.setContrastValue( 30 ); hExtremaWatershedByBlockAlgo.setOutputType( HExtremaWatershedByBlock::OutputType::SEPARATED_OBJECTS ); hExtremaWatershedByBlockAlgo.setAlgorithmMode( HExtremaWatershedByBlock::AlgorithmMode::REPEATABLE ); hExtremaWatershedByBlockAlgo.setBlockSize( 256 ); hExtremaWatershedByBlockAlgo.setNeighborhood( HExtremaWatershedByBlock::Neighborhood::CONNECTIVITY_26 ); hExtremaWatershedByBlockAlgo.execute(); std::cout << "outputImage:" << hExtremaWatershedByBlockAlgo.outputImage()->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip")) h_extrema_watershed_by_block_algo = imagedev.HExtremaWatershedByBlock() h_extrema_watershed_by_block_algo.input_gray_image = foam h_extrema_watershed_by_block_algo.object_lightness = imagedev.HExtremaWatershedByBlock.DARK_OBJECTS h_extrema_watershed_by_block_algo.contrast_value = 30 h_extrema_watershed_by_block_algo.output_type = imagedev.HExtremaWatershedByBlock.SEPARATED_OBJECTS h_extrema_watershed_by_block_algo.algorithm_mode = imagedev.HExtremaWatershedByBlock.REPEATABLE h_extrema_watershed_by_block_algo.block_size = 256 h_extrema_watershed_by_block_algo.neighborhood = imagedev.HExtremaWatershedByBlock.CONNECTIVITY_26 h_extrema_watershed_by_block_algo.execute() print( "output_image:", str( h_extrema_watershed_by_block_algo.output_image ) );
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" ); HExtremaWatershedByBlock hExtremaWatershedByBlockAlgo = new HExtremaWatershedByBlock { inputGrayImage = foam, objectLightness = HExtremaWatershedByBlock.ObjectLightness.DARK_OBJECTS, contrastValue = 30, outputType = HExtremaWatershedByBlock.OutputType.SEPARATED_OBJECTS, algorithmMode = HExtremaWatershedByBlock.AlgorithmMode.REPEATABLE, blockSize = 256, neighborhood = HExtremaWatershedByBlock.Neighborhood.CONNECTIVITY_26 }; hExtremaWatershedByBlockAlgo.Execute(); Console.WriteLine( "outputImage:" + hExtremaWatershedByBlockAlgo.outputImage.ToString() );
Function Examples
auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" ); auto result = hExtremaWatershedByBlock( foam, HExtremaWatershedByBlock::ObjectLightness::DARK_OBJECTS, 30, HExtremaWatershedByBlock::OutputType::SEPARATED_OBJECTS, HExtremaWatershedByBlock::AlgorithmMode::REPEATABLE, 256, HExtremaWatershedByBlock::Neighborhood::CONNECTIVITY_26 ); std::cout << "outputImage:" << result->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip")) result = imagedev.h_extrema_watershed_by_block( foam, imagedev.HExtremaWatershedByBlock.DARK_OBJECTS, 30, imagedev.HExtremaWatershedByBlock.SEPARATED_OBJECTS, imagedev.HExtremaWatershedByBlock.REPEATABLE, 256, imagedev.HExtremaWatershedByBlock.CONNECTIVITY_26 ) print( "output_image:", str( result ) );
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" ); IOLink.ImageView result = Processing.HExtremaWatershedByBlock( foam, HExtremaWatershedByBlock.ObjectLightness.DARK_OBJECTS, 30, HExtremaWatershedByBlock.OutputType.SEPARATED_OBJECTS, HExtremaWatershedByBlock.AlgorithmMode.REPEATABLE, 256, HExtremaWatershedByBlock.Neighborhood.CONNECTIVITY_26 ); Console.WriteLine( "outputImage:" + result.ToString() );