ImageDev

KillBorder2d

Removes the objects connected to the borders of a segmented 2D image.

Access to parameter description

For an introduction: This algorithm removes all the objects touching the borders of the 2D image.
Objects connected to the label image borders are identified using a numerical reconstruction from markers made of pixels of the image frame. Then we remove these objects from the input image with a logical subtraction.

To reorder labels use ReorderLabels algorithm

<b> Figure 1. </b> Illustration of the BorderKill algorithm
Figure 1. Illustration of the BorderKill algorithm

See also
See related examples

Function Syntax

This function returns outputObjectImage.
// Function prototype
std::shared_ptr< iolink::ImageView > killBorder2d( std::shared_ptr< iolink::ImageView > inputObjectImage, KillBorder2d::Neighborhood neighborhood, std::shared_ptr< iolink::ImageView > outputObjectImage = NULL );
This function returns outputObjectImage.
// Function prototype.
kill_border_2d( input_object_image, neighborhood = KillBorder2d.Neighborhood.CONNECTIVITY_8, output_object_image = None )
This function returns outputObjectImage.
// Function prototype.
public static IOLink.ImageView
KillBorder2d( IOLink.ImageView inputObjectImage,
              KillBorder2d.Neighborhood neighborhood = ImageDev.KillBorder2d.Neighborhood.CONNECTIVITY_8,
              IOLink.ImageView outputObjectImage = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputObjectImage
The input binary or label image. Image Binary or Label nullptr
input
neighborhood
The 2D neighborhood configuration.
CONNECTIVITY_4 Morphological reconstruction is performed with a 4-neighbor connectivity.
CONNECTIVITY_8 Morphological reconstruction is performed with a 8-neighbor connectivity.
Enumeration CONNECTIVITY_8
output
outputObjectImage
The output binary or label image. Its dimensions and type are forced to the same values as the input. Image nullptr
Parameter Name Description Type Supported Values Default Value
input
input_object_image
The input binary or label image. image Binary or Label None
input
neighborhood
The 2D neighborhood configuration.
CONNECTIVITY_4 Morphological reconstruction is performed with a 4-neighbor connectivity.
CONNECTIVITY_8 Morphological reconstruction is performed with a 8-neighbor connectivity.
enumeration CONNECTIVITY_8
output
output_object_image
The output binary or label image. Its dimensions and type are forced to the same values as the input. image None
Parameter Name Description Type Supported Values Default Value
input
inputObjectImage
The input binary or label image. Image Binary or Label null
input
neighborhood
The 2D neighborhood configuration.
CONNECTIVITY_4 Morphological reconstruction is performed with a 4-neighbor connectivity.
CONNECTIVITY_8 Morphological reconstruction is performed with a 8-neighbor connectivity.
Enumeration CONNECTIVITY_8
output
outputObjectImage
The output binary or label image. Its dimensions and type are forced to the same values as the input. Image null

Object Examples

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

KillBorder2d killBorder2dAlgo;
killBorder2dAlgo.setInputObjectImage( polystyrene_lab_seq );
killBorder2dAlgo.setNeighborhood( KillBorder2d::Neighborhood::CONNECTIVITY_8 );
killBorder2dAlgo.execute();

std::cout << "outputObjectImage:" << killBorder2dAlgo.outputObjectImage()->toString();
polystyrene_lab_seq = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_lab_seq.vip"))

kill_border_2d_algo = imagedev.KillBorder2d()
kill_border_2d_algo.input_object_image = polystyrene_lab_seq
kill_border_2d_algo.neighborhood = imagedev.KillBorder2d.CONNECTIVITY_8
kill_border_2d_algo.execute()

print( "output_object_image:", str( kill_border_2d_algo.output_object_image ) )
ImageView polystyrene_lab_seq = Data.ReadVipImage( @"Data/images/polystyrene_lab_seq.vip" );

KillBorder2d killBorder2dAlgo = new KillBorder2d
{
    inputObjectImage = polystyrene_lab_seq,
    neighborhood = KillBorder2d.Neighborhood.CONNECTIVITY_8
};
killBorder2dAlgo.Execute();

Console.WriteLine( "outputObjectImage:" + killBorder2dAlgo.outputObjectImage.ToString() );

Function Examples

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

auto result = killBorder2d( polystyrene_lab_seq, KillBorder2d::Neighborhood::CONNECTIVITY_8 );

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

result = imagedev.kill_border_2d( polystyrene_lab_seq, imagedev.KillBorder2d.CONNECTIVITY_8 )

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

IOLink.ImageView result = Processing.KillBorder2d( polystyrene_lab_seq, KillBorder2d.Neighborhood.CONNECTIVITY_8 );

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