ImageDev

SeparateObjectsByBlock

Separates connected objects in a binary image in a low memory consumption mode.

Access to parameter description

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

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: See also

Function Syntax

This function returns the outputImage output parameter.
// 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 = NULL );
This function returns the outputImage output parameter.
// Function prototype.
separate_objects_by_block( input_binary_image,
                           contrast_value = 4,
                           output_type = SeparateObjectsByBlock.OutputType.SEPARATED_OBJECTS,
                           algorithm_mode = SeparateObjectsByBlock.AlgorithmMode.REPEATABLE,
                           block_size = 256,
                           neighborhood = SeparateObjectsByBlock.Neighborhood.CONNECTIVITY_26,
                           output_image = None )
This function returns the outputImage output parameter.
// 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

Class Name SeparateObjectsByBlock

Parameter Name Description Type Supported Values Default Value
input
inputBinaryImage
The input binary image. Image Binary nullptr
input
contrastValue
The depth of the valley used to select the markers of the watershed. Int32 >=0 4
input
outputType
The type of result image.
SEPARATED_OBJECTS The result image is a binary image representing the original data minus separation lines (split particles).
WATERSHED_RIDGES The result image is a binary image representing the separation lines (watershed).
SEPARATED_BASINS The result image is a label image representing the catchment areas (labeled complement of the watershed).
CONTIGUOUS_BASINS The result image is a label image representing the catchment areas with separation lines filled by a label.
CONTIGUOUS_OBJECTS The result image is a label image representing the original image with labels taking into account the watershed.
Enumeration SEPARATED_OBJECTS
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
input
neighborhood
The 3D neighborhood configuration. This parameter is ignored with a 2D input image.
CONNECTIVITY_6 The structuring element is composed of voxels with a common face with the voxel of interest.
CONNECTIVITY_18 The structuring element is composed of voxels with at least one common edge.
CONNECTIVITY_26 The structuring element is a full cube.
Enumeration CONNECTIVITY_26
output
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

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