ImageDev

ExpandLabelBoundaries

Performs a constrained dilation around objects of a label image.

Access to parameter description

For an introduction: This algorithm performs a label expansion around each object of a label image.

Its first aim is to expand labels obtained by a segmentation algorithm producing objects separated by a background line like MarkerBasedWatershed. It fills all black pixels around object boundaries with the value of the most present label among its height neighbors.


<b>(a)</b>
(a)
<b>(b)</b>
(b)
Figure 1. Label boundaries expansion applied to the result of MarkerBasedWatershed algorithm: (a) input label image, (b) image after label expansion


See also

Function Syntax

This function returns outputLabelImage.
// Function prototype
std::shared_ptr< iolink::ImageView > expandLabelBoundaries( std::shared_ptr< iolink::ImageView > inputLabelImage, ExpandLabelBoundaries::Neighborhood neighborhood, std::shared_ptr< iolink::ImageView > outputLabelImage = NULL );
This function returns outputLabelImage.
// Function prototype.
expand_label_boundaries( input_label_image, neighborhood = ExpandLabelBoundaries.Neighborhood.CONNECTIVITY_26, output_label_image = None )
This function returns outputLabelImage.
// Function prototype.
public static IOLink.ImageView
ExpandLabelBoundaries( IOLink.ImageView inputLabelImage,
                       ExpandLabelBoundaries.Neighborhood neighborhood = ImageDev.ExpandLabelBoundaries.Neighborhood.CONNECTIVITY_26,
                       IOLink.ImageView outputLabelImage = null );

Class Syntax

Parameters

Class Name ExpandLabelBoundaries

Parameter Name Description Type Supported Values Default Value
input
inputLabelImage
The input label image. Image Label nullptr
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
outputLabelImage
The output label image. Its dimensions are forced to the same values as the input image. Image nullptr

Object Examples

auto foam_sep_label = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam_sep_label.vip" );

ExpandLabelBoundaries expandLabelBoundariesAlgo;
expandLabelBoundariesAlgo.setInputLabelImage( foam_sep_label );
expandLabelBoundariesAlgo.setNeighborhood( ExpandLabelBoundaries::Neighborhood::CONNECTIVITY_26 );
expandLabelBoundariesAlgo.execute();

std::cout << "outputLabelImage:" << expandLabelBoundariesAlgo.outputLabelImage()->toString();
foam_sep_label = imagedev.read_vip_image(imagedev_data.get_image_path("foam_sep_label.vip"))

expand_label_boundaries_algo = imagedev.ExpandLabelBoundaries()
expand_label_boundaries_algo.input_label_image = foam_sep_label
expand_label_boundaries_algo.neighborhood = imagedev.ExpandLabelBoundaries.CONNECTIVITY_26
expand_label_boundaries_algo.execute()

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

ExpandLabelBoundaries expandLabelBoundariesAlgo = new ExpandLabelBoundaries
{
    inputLabelImage = foam_sep_label,
    neighborhood = ExpandLabelBoundaries.Neighborhood.CONNECTIVITY_26
};
expandLabelBoundariesAlgo.Execute();

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

Function Examples

auto foam_sep_label = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam_sep_label.vip" );

auto result = expandLabelBoundaries( foam_sep_label, ExpandLabelBoundaries::Neighborhood::CONNECTIVITY_26 );

std::cout << "outputLabelImage:" << result->toString();
foam_sep_label = imagedev.read_vip_image(imagedev_data.get_image_path("foam_sep_label.vip"))

result = imagedev.expand_label_boundaries( foam_sep_label, imagedev.ExpandLabelBoundaries.CONNECTIVITY_26 )

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

IOLink.ImageView result = Processing.ExpandLabelBoundaries( foam_sep_label, ExpandLabelBoundaries.Neighborhood.CONNECTIVITY_26 );

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