ImageDev

OpeningDiskByReconstruction2d

Performs a two-dimensional opening by reconstruction with a structuring element matching with a disk.

Access to parameter description

An opening by reconstruction consists in applying an erosion followed by a morphological reconstruction. In the binary case, opening by reconstruction can be used for removing small objects without modifying edges of the large ones. In the grayscale case, opening by reconstruction can be used for performing a Top Hat by reconstruction for detecting bright small structures without getting artifacts from the boundary concavities of the large ones.
Its 2D binary behavior is illustrated in the OpeningByReconstruction2d documentation (Figure 1).

This algorithm supports two modes: a fast mode that combines erosions and dilations using different neighborhoods, and a precise mode (slower) that ensures a real disk structuring element. The mode can be selected with the precision parameter.

See also

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > openingDiskByReconstruction2d( std::shared_ptr< iolink::ImageView > inputImage, uint32_t kernelRadius, OpeningDiskByReconstruction2d::Precision precision, std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns outputImage.
// Function prototype.
opening_disk_by_reconstruction_2d( input_image,
                                   kernel_radius = 3,
                                   precision = OpeningDiskByReconstruction2d.Precision.FASTER,
                                   output_image = None )
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
OpeningDiskByReconstruction2d( IOLink.ImageView inputImage,
                               UInt32 kernelRadius = 3,
                               OpeningDiskByReconstruction2d.Precision precision = ImageDev.OpeningDiskByReconstruction2d.Precision.FASTER,
                               IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label or Grayscale nullptr
input
kernelRadius
The length of the disk radius in pixels. UInt32 >=1 3
input
precision
The precision of the computation method.
FASTER The operation is computed with a fast mode, which approximates a circular structuring element by combining erosions using 8 and 4 neighborhoods.
PRECISE The operation is computed with a precise mode (slower), which ensures a real circular structuring element.
Enumeration FASTER
output
outputImage
The output image. Its dimensions and type are forced to the same values as the input image. Image nullptr
Parameter Name Description Type Supported Values Default Value
input
input_image
The input image. image Binary, Label or Grayscale None
input
kernel_radius
The length of the disk radius in pixels. uint32 >=1 3
input
precision
The precision of the computation method.
FASTER The operation is computed with a fast mode, which approximates a circular structuring element by combining erosions using 8 and 4 neighborhoods.
PRECISE The operation is computed with a precise mode (slower), which ensures a real circular structuring element.
enumeration FASTER
output
output_image
The output image. Its dimensions and type are forced to the same values as the input image. image None
Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label or Grayscale null
input
kernelRadius
The length of the disk radius in pixels. UInt32 >=1 3
input
precision
The precision of the computation method.
FASTER The operation is computed with a fast mode, which approximates a circular structuring element by combining erosions using 8 and 4 neighborhoods.
PRECISE The operation is computed with a precise mode (slower), which ensures a real circular structuring element.
Enumeration FASTER
output
outputImage
The output image. Its dimensions and type are forced to the same values as the input image. Image null

Object Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

OpeningDiskByReconstruction2d openingDiskByReconstruction2dAlgo;
openingDiskByReconstruction2dAlgo.setInputImage( polystyrene );
openingDiskByReconstruction2dAlgo.setKernelRadius( 3 );
openingDiskByReconstruction2dAlgo.setPrecision( OpeningDiskByReconstruction2d::Precision::FASTER );
openingDiskByReconstruction2dAlgo.execute();

std::cout << "outputImage:" << openingDiskByReconstruction2dAlgo.outputImage()->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

opening_disk_by_reconstruction_2d_algo = imagedev.OpeningDiskByReconstruction2d()
opening_disk_by_reconstruction_2d_algo.input_image = polystyrene
opening_disk_by_reconstruction_2d_algo.kernel_radius = 3
opening_disk_by_reconstruction_2d_algo.precision = imagedev.OpeningDiskByReconstruction2d.FASTER
opening_disk_by_reconstruction_2d_algo.execute()

print( "output_image:", str( opening_disk_by_reconstruction_2d_algo.output_image ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

OpeningDiskByReconstruction2d openingDiskByReconstruction2dAlgo = new OpeningDiskByReconstruction2d
{
    inputImage = polystyrene,
    kernelRadius = 3,
    precision = OpeningDiskByReconstruction2d.Precision.FASTER
};
openingDiskByReconstruction2dAlgo.Execute();

Console.WriteLine( "outputImage:" + openingDiskByReconstruction2dAlgo.outputImage.ToString() );

Function Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

auto result = openingDiskByReconstruction2d( polystyrene, 3, OpeningDiskByReconstruction2d::Precision::FASTER );

std::cout << "outputImage:" << result->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

result = imagedev.opening_disk_by_reconstruction_2d( polystyrene, 3, imagedev.OpeningDiskByReconstruction2d.FASTER )

print( "output_image:", str( result ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

IOLink.ImageView result = Processing.OpeningDiskByReconstruction2d( polystyrene, 3, OpeningDiskByReconstruction2d.Precision.FASTER );

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