ImageDev

OpeningLine2d

Performs a two-dimensional opening using a structuring element matching with a line.

Access to parameter description

For an introduction: This algorithm successively runs an ErosionLine2d and a DilationLine2d with the same kernel in the opposite direction. A linear opening controls the direction of the opening, therefore making it possible to remove objects and isthmi thinner than the structuring element in its direction.
The opening is performed by using a linear structuring element. The direction of 0 degrees is horizontal and to the left, and the angles are calculated counter-clockwise.

With a classic implementation, morphological opening systematically considers areas out of the image as a replication of the image borders at each step of the algorithm. Therefore, when applying an opening, some thin object parts cut by the image borders may be removed at the erosion step and not be restored after the dilation, while one would expect to keep them. The borderPolicy parameter manages this case. The default mode, LIMITED, corresponds to the classic behavior. The EXTENDED mode manages properly image borders by extending them by a size equal to the structuring element's. This mode can be slower and more memory consuming, especially when the structuring element size is high.
This option is illustrated in the Opening2d documentation (Figure 2).

See also

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > openingLine2d( std::shared_ptr< iolink::ImageView > inputImage, double orientationAngle, uint32_t kernelRadius, OpeningLine2d::BorderPolicy borderPolicy, std::shared_ptr< iolink::ImageView > outputImage = nullptr );
This function returns outputImage.
// Function prototype.
opening_line_2d(input_image: idt.ImageType,
                orientation_angle: float = 10,
                kernel_radius: int = 3,
                border_policy: OpeningLine2d.BorderPolicy = OpeningLine2d.BorderPolicy.LIMITED,
                output_image: idt.ImageType = None) -> idt.ImageType
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
OpeningLine2d( IOLink.ImageView inputImage,
               double orientationAngle = 10,
               UInt32 kernelRadius = 3,
               OpeningLine2d.BorderPolicy borderPolicy = ImageDev.OpeningLine2d.BorderPolicy.LIMITED,
               IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. The image type can be integer or float. Image Binary, Label, Grayscale or Multispectral nullptr
input
borderPolicy
The border policy to apply.
LIMITED The limited mode is faster to compute, but can produce the unexpected results for particles close to the image border.
EXTENDED The Extended mode is slower to compute, but produces the expected results for particles close to the image border.
Enumeration LIMITED
input
orientationAngle
The angle of orientation in degrees. Float64 Any value 10
input
kernelRadius
The length of the linear structuring element in pixels. UInt32 >=1 3
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. The image type can be integer or float. image Binary, Label, Grayscale or Multispectral None
input
border_policy
The border policy to apply.
LIMITED The limited mode is faster to compute, but can produce the unexpected results for particles close to the image border.
EXTENDED The Extended mode is slower to compute, but produces the expected results for particles close to the image border.
enumeration LIMITED
input
orientation_angle
The angle of orientation in degrees. float64 Any value 10
input
kernel_radius
The length of the linear structuring element in pixels. uint32 >=1 3
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. The image type can be integer or float. Image Binary, Label, Grayscale or Multispectral null
input
borderPolicy
The border policy to apply.
LIMITED The limited mode is faster to compute, but can produce the unexpected results for particles close to the image border.
EXTENDED The Extended mode is slower to compute, but produces the expected results for particles close to the image border.
Enumeration LIMITED
input
orientationAngle
The angle of orientation in degrees. Float64 Any value 10
input
kernelRadius
The length of the linear structuring element in pixels. UInt32 >=1 3
output
outputImage
The output image. Its dimensions and type are forced to the same values as the input image. Image null

Object Examples

auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

OpeningLine2d openingLine2dAlgo;
openingLine2dAlgo.setInputImage( polystyrene );
openingLine2dAlgo.setOrientationAngle( 10 );
openingLine2dAlgo.setKernelRadius( 3 );
openingLine2dAlgo.setBorderPolicy( OpeningLine2d::BorderPolicy::EXTENDED );
openingLine2dAlgo.execute();

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

opening_line_2d_algo = imagedev.OpeningLine2d()
opening_line_2d_algo.input_image = polystyrene
opening_line_2d_algo.orientation_angle = 10
opening_line_2d_algo.kernel_radius = 3
opening_line_2d_algo.border_policy = imagedev.OpeningLine2d.EXTENDED
opening_line_2d_algo.execute()

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

OpeningLine2d openingLine2dAlgo = new OpeningLine2d
{
    inputImage = polystyrene,
    orientationAngle = 10,
    kernelRadius = 3,
    borderPolicy = OpeningLine2d.BorderPolicy.EXTENDED
};
openingLine2dAlgo.Execute();

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

Function Examples

auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

auto result = openingLine2d( polystyrene, 10, 3, OpeningLine2d::BorderPolicy::EXTENDED );

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

result = imagedev.opening_line_2d(polystyrene, 10, 3, imagedev.OpeningLine2d.EXTENDED)

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

IOLink.ImageView result = Processing.OpeningLine2d( polystyrene, 10, 3, OpeningLine2d.BorderPolicy.EXTENDED );

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