ImageDev

SelectiveErosion2d

Erodes objects of a two-dimensional binary image conditionally to a local constraint.

Access to parameter description

For an introduction: This algorithm can be applied only on binary images. It is performed iteratively and at each step a foreground pixel is transformed into a background pixel if the number of background pixels in its 8-neighborhood is greater than or equal to a specified threshold.
Using a threshold of 1 amounts to applying a standard morphological erosion.

This operator is smoother than a standard erosion, and softens the appearance of the structuring element in the filtered image.

<b> (a) </b>
(a)
<b> (b) </b>
(b)
<b> (c) </b>
(c)
Figure 1. Selective erosion effect: (a) The binary input image,
(b) standard erosion with 3 iterations, (c) selective erosion with 3 iterations, threshold = 5

See also

Function Syntax

This function returns the outputBinaryImage output parameter.
// Function prototype.
std::shared_ptr< iolink::ImageView >
selectiveErosion2d( std::shared_ptr< iolink::ImageView > inputBinaryImage,
                    uint32_t numberOfIterations,
                    uint32_t threshold,
                    std::shared_ptr< iolink::ImageView > outputBinaryImage = NULL );
This function returns the outputBinaryImage output parameter.
// Function prototype.
selective_erosion_2d( input_binary_image,
                      number_of_iterations = 3,
                      threshold = 5,
                      output_binary_image = None )
This function returns the outputBinaryImage output parameter.
// Function prototype.
public static IOLink.ImageView
SelectiveErosion2d( IOLink.ImageView inputBinaryImage,
                    UInt32 numberOfIterations = 3,
                    UInt32 threshold = 5,
                    IOLink.ImageView outputBinaryImage = null );

Class Syntax

Parameters

Class Name SelectiveErosion2d

Parameter Name Description Type Supported Values Default Value
input
inputBinaryImage
The binary input image. Image Binary nullptr
input
numberOfIterations
The number of iterations. UInt32 >=1 3
input
threshold
The minimum number of background neighbors that is required to transform a foreground pixel into a background one. UInt32 [1, 8] 5
output
outputBinaryImage
The binary output image. Its size and type are forced to the same values as the input. Image nullptr

Object Examples

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

SelectiveErosion2d selectiveErosion2dAlgo;
selectiveErosion2dAlgo.setInputBinaryImage( polystyrene_sep );
selectiveErosion2dAlgo.setNumberOfIterations( 3 );
selectiveErosion2dAlgo.setThreshold( 5 );
selectiveErosion2dAlgo.execute();

std::cout << "outputBinaryImage:" << selectiveErosion2dAlgo.outputBinaryImage()->toString();
polystyrene_sep = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep.vip"))

selective_erosion_2d_algo = imagedev.SelectiveErosion2d()
selective_erosion_2d_algo.input_binary_image = polystyrene_sep
selective_erosion_2d_algo.number_of_iterations = 3
selective_erosion_2d_algo.threshold = 5
selective_erosion_2d_algo.execute()

print( "output_binary_image:", str( selective_erosion_2d_algo.output_binary_image ) )
ImageView polystyrene_sep = Data.ReadVipImage( @"Data/images/polystyrene_sep.vip" );

SelectiveErosion2d selectiveErosion2dAlgo = new SelectiveErosion2d
{
    inputBinaryImage = polystyrene_sep,
    numberOfIterations = 3,
    threshold = 5
};
selectiveErosion2dAlgo.Execute();

Console.WriteLine( "outputBinaryImage:" + selectiveErosion2dAlgo.outputBinaryImage.ToString() );

Function Examples

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

auto result = selectiveErosion2d( polystyrene_sep, 3, 5 );

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

result = imagedev.selective_erosion_2d( polystyrene_sep, 3, 5 )

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

IOLink.ImageView result = Processing.SelectiveErosion2d( polystyrene_sep, 3, 5 );

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