ImageDev

ClosingBall3d

Performs a three-dimensional closing using a structuring element matching with a sphere.

Access to parameter description

For an introduction: This algorithm successively runs a DilationBall3d and an ErosionBall3d with the same kernel. This command supports two modes: a fast mode that approximates a spherical structuring element by combining erosions and dilations using 6, 18 and 26 neighborhoods, and a precise mode (slower) that ensures a real spherical structuring element. The mode can be selected with the precision parameter.

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

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > closingBall3d( std::shared_ptr< iolink::ImageView > inputImage, uint32_t kernelRadius, ClosingBall3d::Precision precision, ClosingBall3d::BorderPolicy borderPolicy, std::shared_ptr< iolink::ImageView > outputImage = nullptr );
This function returns outputImage.
// Function prototype.
closing_ball_3d(input_image: idt.ImageType,
                kernel_radius: int = 3,
                precision: ClosingBall3d.Precision = ClosingBall3d.Precision.FASTER,
                border_policy: ClosingBall3d.BorderPolicy = ClosingBall3d.BorderPolicy.LIMITED,
                output_image: idt.ImageType = None) -> idt.ImageType
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
ClosingBall3d( IOLink.ImageView inputImage,
               UInt32 kernelRadius = 3,
               ClosingBall3d.Precision precision = ImageDev.ClosingBall3d.Precision.FASTER,
               ClosingBall3d.BorderPolicy borderPolicy = ImageDev.ClosingBall3d.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 length of the sphere radius in voxels. 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 6, 18 and 26 neighborhoods.
PRECISE The operation is computed with a precise mode (slower), which ensures a real spherical 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. 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 length of the sphere radius in voxels. 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 6, 18 and 26 neighborhoods.
PRECISE The operation is computed with a precise mode (slower), which ensures a real spherical 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. 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 length of the sphere radius in voxels. 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 6, 18 and 26 neighborhoods.
PRECISE The operation is computed with a precise mode (slower), which ensures a real spherical 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

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

ClosingBall3d closingBall3dAlgo;
closingBall3dAlgo.setInputImage( foam );
closingBall3dAlgo.setKernelRadius( 3 );
closingBall3dAlgo.setPrecision( ClosingBall3d::Precision::FASTER );
closingBall3dAlgo.setBorderPolicy( ClosingBall3d::BorderPolicy::EXTENDED );
closingBall3dAlgo.execute();

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

closing_ball_3d_algo = imagedev.ClosingBall3d()
closing_ball_3d_algo.input_image = foam
closing_ball_3d_algo.kernel_radius = 3
closing_ball_3d_algo.precision = imagedev.ClosingBall3d.FASTER
closing_ball_3d_algo.border_policy = imagedev.ClosingBall3d.EXTENDED
closing_ball_3d_algo.execute()

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

ClosingBall3d closingBall3dAlgo = new ClosingBall3d
{
    inputImage = foam,
    kernelRadius = 3,
    precision = ClosingBall3d.Precision.FASTER,
    borderPolicy = ClosingBall3d.BorderPolicy.EXTENDED
};
closingBall3dAlgo.Execute();

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

Function Examples

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

auto result = closingBall3d( foam, 3, ClosingBall3d::Precision::FASTER, ClosingBall3d::BorderPolicy::EXTENDED );

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

result = imagedev.closing_ball_3d(foam, 3, imagedev.ClosingBall3d.FASTER, imagedev.ClosingBall3d.EXTENDED)

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

IOLink.ImageView result = Processing.ClosingBall3d( foam, 3, ClosingBall3d.Precision.FASTER, ClosingBall3d.BorderPolicy.EXTENDED );

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