SeparateObjectsByBlock
Separates connected objects in a binary 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 SeparateObjects 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 distance map generates some plateaus.
Function Syntax
This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > separateObjectsByBlock( std::shared_ptr< iolink::ImageView > inputBinaryImage, int32_t contrastValue, SeparateObjectsByBlock::OutputType outputType, SeparateObjectsByBlock::AlgorithmMode algorithmMode, int32_t blockSize, SeparateObjectsByBlock::Neighborhood neighborhood, std::shared_ptr< iolink::ImageView > outputImage = nullptr );
This function returns outputImage.
// Function prototype. separate_objects_by_block(input_binary_image: idt.ImageType, contrast_value: int = 4, output_type: SeparateObjectsByBlock.OutputType = SeparateObjectsByBlock.OutputType.SEPARATED_OBJECTS, algorithm_mode: SeparateObjectsByBlock.AlgorithmMode = SeparateObjectsByBlock.AlgorithmMode.REPEATABLE, block_size: int = 256, neighborhood: SeparateObjectsByBlock.Neighborhood = SeparateObjectsByBlock.Neighborhood.CONNECTIVITY_26, output_image: idt.ImageType = None) -> idt.ImageType
This function returns outputImage.
// Function prototype. public static IOLink.ImageView SeparateObjectsByBlock( IOLink.ImageView inputBinaryImage, Int32 contrastValue = 4, SeparateObjectsByBlock.OutputType outputType = ImageDev.SeparateObjectsByBlock.OutputType.SEPARATED_OBJECTS, SeparateObjectsByBlock.AlgorithmMode algorithmMode = ImageDev.SeparateObjectsByBlock.AlgorithmMode.REPEATABLE, Int32 blockSize = 256, SeparateObjectsByBlock.Neighborhood neighborhood = ImageDev.SeparateObjectsByBlock.Neighborhood.CONNECTIVITY_26, IOLink.ImageView outputImage = null );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
inputBinaryImage |
The input binary image. | Image | Binary | nullptr | |||||||||||
contrastValue |
The depth of the valley used to select the markers of the watershed. | Int32 | >=0 | 4 | |||||||||||
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 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 |
Parameter Name | Description | Type | Supported Values | Default Value | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
input_binary_image |
The input binary image. | image | Binary | None | |||||||||||
contrast_value |
The depth of the valley used to select the markers of the watershed. | int32 | >=0 | 4 | |||||||||||
output_type |
The type of result image.
|
enumeration | SEPARATED_OBJECTS | ||||||||||||
algorithm_mode |
The mode for applying the watershed algorithm.
|
enumeration | REPEATABLE | ||||||||||||
block_size |
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 | ||||||||||||
output_image |
The output binary or label image. Its dimensions are forced to the same values as the input image. Its type depends on the outputType parameter. | image | None |
Parameter Name | Description | Type | Supported Values | Default Value | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
inputBinaryImage |
The input binary image. | Image | Binary | null | |||||||||||
contrastValue |
The depth of the valley used to select the markers of the watershed. | Int32 | >=0 | 4 | |||||||||||
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 binary or label image. Its dimensions are forced to the same values as the input image. Its type depends on the outputType parameter. | Image | null |
Object Examples
auto polystyrene_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep.vip" ); SeparateObjectsByBlock separateObjectsByBlockAlgo; separateObjectsByBlockAlgo.setInputBinaryImage( polystyrene_sep ); separateObjectsByBlockAlgo.setContrastValue( 4 ); separateObjectsByBlockAlgo.setOutputType( SeparateObjectsByBlock::OutputType::SEPARATED_OBJECTS ); separateObjectsByBlockAlgo.setAlgorithmMode( SeparateObjectsByBlock::AlgorithmMode::REPEATABLE ); separateObjectsByBlockAlgo.setBlockSize( 256 ); separateObjectsByBlockAlgo.setNeighborhood( SeparateObjectsByBlock::Neighborhood::CONNECTIVITY_26 ); separateObjectsByBlockAlgo.execute(); std::cout << "outputImage:" << separateObjectsByBlockAlgo.outputImage()->toString();
polystyrene_sep = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep.vip")) separate_objects_by_block_algo = imagedev.SeparateObjectsByBlock() separate_objects_by_block_algo.input_binary_image = polystyrene_sep separate_objects_by_block_algo.contrast_value = 4 separate_objects_by_block_algo.output_type = imagedev.SeparateObjectsByBlock.SEPARATED_OBJECTS separate_objects_by_block_algo.algorithm_mode = imagedev.SeparateObjectsByBlock.REPEATABLE separate_objects_by_block_algo.block_size = 256 separate_objects_by_block_algo.neighborhood = imagedev.SeparateObjectsByBlock.CONNECTIVITY_26 separate_objects_by_block_algo.execute() print("output_image:", str(separate_objects_by_block_algo.output_image))
ImageView polystyrene_sep = Data.ReadVipImage( @"Data/images/polystyrene_sep.vip" ); SeparateObjectsByBlock separateObjectsByBlockAlgo = new SeparateObjectsByBlock { inputBinaryImage = polystyrene_sep, contrastValue = 4, outputType = SeparateObjectsByBlock.OutputType.SEPARATED_OBJECTS, algorithmMode = SeparateObjectsByBlock.AlgorithmMode.REPEATABLE, blockSize = 256, neighborhood = SeparateObjectsByBlock.Neighborhood.CONNECTIVITY_26 }; separateObjectsByBlockAlgo.Execute(); Console.WriteLine( "outputImage:" + separateObjectsByBlockAlgo.outputImage.ToString() );
Function Examples
auto polystyrene_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep.vip" ); auto result = separateObjectsByBlock( polystyrene_sep, 4, SeparateObjectsByBlock::OutputType::SEPARATED_OBJECTS, SeparateObjectsByBlock::AlgorithmMode::REPEATABLE, 256, SeparateObjectsByBlock::Neighborhood::CONNECTIVITY_26 ); std::cout << "outputImage:" << result->toString();
polystyrene_sep = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep.vip")) result = imagedev.separate_objects_by_block(polystyrene_sep, 4, imagedev.SeparateObjectsByBlock.SEPARATED_OBJECTS, imagedev.SeparateObjectsByBlock.REPEATABLE, 256, imagedev.SeparateObjectsByBlock.CONNECTIVITY_26) print("output_image:", str(result))
ImageView polystyrene_sep = Data.ReadVipImage( @"Data/images/polystyrene_sep.vip" ); IOLink.ImageView result = Processing.SeparateObjectsByBlock( polystyrene_sep, 4, SeparateObjectsByBlock.OutputType.SEPARATED_OBJECTS, SeparateObjectsByBlock.AlgorithmMode.REPEATABLE, 256, SeparateObjectsByBlock.Neighborhood.CONNECTIVITY_26 ); Console.WriteLine( "outputImage:" + result.ToString() );