ImageDev

Closing3d

Performs a three-dimensional opening using a structuring element matching with a with a full or partial cube.

Access to parameter description

For an introduction: This algorithm successively runs a Dilation3d and an Erosion3d with the same kernel.
The kernelRadius parameter tunes the number of iterations of each operation, which sets the kernel size.
This algorithm uses a basic structuring element with 6, 18 or 26 neighbors, according to the neighborhood parameter.

<b> Figure 1.</b> Structuring elements: 6, 18 and 26 neighbors
Figure 1. Structuring elements: 6, 18 and 26 neighbors

With a classic implementation, morphological closing systematically considers areas out of the image as a replication of the image borders at each step of the algorithm. Therefore, when applying a closing, some objects close to the image borders may be connected to the border at the dilation step and not be retro propagated after the dilation, while one would expect to keep them disconnected from the border. The borderPolicy parameter manages this case. The default mode, LIMITED, corresponds to the classic behavior. The EXTENDED mode properly manages 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 Closing2d documentation (Figure 2).

See also
See related example

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > closing3d( std::shared_ptr< iolink::ImageView > inputImage, uint32_t kernelRadius, Closing3d::Neighborhood neighborhood, Closing3d::BorderPolicy borderPolicy, std::shared_ptr< iolink::ImageView > outputImage = nullptr );
This function returns outputImage.
// Function prototype.
closing_3d(input_image: idt.ImageType,
           kernel_radius: int = 3,
           neighborhood: Closing3d.Neighborhood = Closing3d.Neighborhood.CONNECTIVITY_26,
           border_policy: Closing3d.BorderPolicy = Closing3d.BorderPolicy.LIMITED,
           output_image: idt.ImageType = None) -> idt.ImageType
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
Closing3d( IOLink.ImageView inputImage,
           UInt32 kernelRadius = 3,
           Closing3d.Neighborhood neighborhood = ImageDev.Closing3d.Neighborhood.CONNECTIVITY_26,
           Closing3d.BorderPolicy borderPolicy = ImageDev.Closing3d.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
kernelRadius
The number of iterations (the half size of the structuring element, in voxels). A cube structuring element always has an odd side length (3x3x3, 5x5x5, etc.) which is defined by twice the kernel radius + 1. UInt32 >=1 3
input
neighborhood
The 3D neighborhood configuration.
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
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
kernel_radius
The number of iterations (the half size of the structuring element, in voxels). A cube structuring element always has an odd side length (3x3x3, 5x5x5, etc.) which is defined by twice the kernel radius + 1. uint32 >=1 3
input
neighborhood
The 3D neighborhood configuration.
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
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
kernelRadius
The number of iterations (the half size of the structuring element, in voxels). A cube structuring element always has an odd side length (3x3x3, 5x5x5, etc.) which is defined by twice the kernel radius + 1. UInt32 >=1 3
input
neighborhood
The 3D neighborhood configuration.
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
outputImage
The output image. Its dimensions and type are forced to the same values as the input image. Image null

Object Examples

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

Closing3d closing3dAlgo;
closing3dAlgo.setInputImage( foam );
closing3dAlgo.setKernelRadius( 3 );
closing3dAlgo.setNeighborhood( Closing3d::Neighborhood::CONNECTIVITY_26 );
closing3dAlgo.setBorderPolicy( Closing3d::BorderPolicy::EXTENDED );
closing3dAlgo.execute();

std::cout << "outputImage:" << closing3dAlgo.outputImage()->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))

closing_3d_algo = imagedev.Closing3d()
closing_3d_algo.input_image = foam
closing_3d_algo.kernel_radius = 3
closing_3d_algo.neighborhood = imagedev.Closing3d.CONNECTIVITY_26
closing_3d_algo.border_policy = imagedev.Closing3d.EXTENDED
closing_3d_algo.execute()

print("output_image:", str(closing_3d_algo.output_image))
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );

Closing3d closing3dAlgo = new Closing3d
{
    inputImage = foam,
    kernelRadius = 3,
    neighborhood = Closing3d.Neighborhood.CONNECTIVITY_26,
    borderPolicy = Closing3d.BorderPolicy.EXTENDED
};
closing3dAlgo.Execute();

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

Function Examples

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

auto result = closing3d( foam, 3, Closing3d::Neighborhood::CONNECTIVITY_26, Closing3d::BorderPolicy::EXTENDED );

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

result = imagedev.closing_3d(foam, 3, imagedev.Closing3d.CONNECTIVITY_26, imagedev.Closing3d.EXTENDED)

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

IOLink.ImageView result = Processing.Closing3d( foam, 3, Closing3d.Neighborhood.CONNECTIVITY_26, Closing3d.BorderPolicy.EXTENDED );

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