ImageDev

MorphologicalGradient3d

Approximates an image gradient by using morphological operations.

Access to parameter description

For an introduction: This algorithm emphasizes the edges of the objects using morphological operations.
Three modes are available to enhance edges inside particles (Internal), outside particles (External) or on the particle borders (Centered).

<b> (a) </b>
(a)
<b> (b) </b>
(b)
<b> (c) </b>
(c)
Figure 1. The Morphological Gradient effects with label image in overlay:
(a) input gray level image, (b) internal morphological gradient, (c) external morphological gradient

This algorithm uses ErosionBall3d or DilationBall3d and combine them as follows: Where $E_B$ (resp. $D_B$) is a morphological erosion (resp. dilation) by a structuring element B.

The morphological gradient can be considered as a non-linear high-pass filter. The bright edges are enhanced with a thickness proportional to the size of the structuring element. It is an approximation of the gradient modulus.

Two additional parameters are also provided: See also

Function Syntax

This function returns the outputImage output parameter.
// Function prototype.
std::shared_ptr< iolink::ImageView >
morphologicalGradient3d( std::shared_ptr< iolink::ImageView > inputImage,
                         uint32_t kernelRadius,
                         MorphologicalGradient3d::GradientMode gradientMode,
                         MorphologicalGradient3d::Precision precision,
                         std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns the outputImage output parameter.
// Function prototype.
morphological_gradient_3d( input_image,
                           kernel_radius = 3,
                           gradient_mode = MorphologicalGradient3d.GradientMode.INTERNAL,
                           precision = MorphologicalGradient3d.Precision.FASTER,
                           output_image = None )
This function returns the outputImage output parameter.
// Function prototype.
public static IOLink.ImageView
MorphologicalGradient3d( IOLink.ImageView inputImage,
                         UInt32 kernelRadius = 3,
                         MorphologicalGradient3d.GradientMode gradientMode = ImageDev.MorphologicalGradient3d.GradientMode.INTERNAL,
                         MorphologicalGradient3d.Precision precision = ImageDev.MorphologicalGradient3d.Precision.FASTER,
                         IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Class Name MorphologicalGradient3d

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
kernelRadius
The radius in pixels of the sphere structuring element used for morphological erosion and dilation. In centered mode, it corresponds to the thickness of the extracted edges and to their half thickness in other modes. UInt32 >=1 3
input
precision
The precision for computation for morphological operations.
FASTER The mophological operations are computed using the fast mode .
PRECISE The mophological operations are computed using the precise mode.
Enumeration FASTER
input
gradientMode
The computation mode of morphological gradient.
INTERNAL The engine emphasizes the internal edges.
EXTERNAL The engine emphasizes the external edges.
CENTERED The engine emphasizes the edges on objects borders.
Enumeration INTERNAL
output
outputImage
The output image. Image nullptr

Object Examples

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

MorphologicalGradient3d morphologicalGradient3dAlgo;
morphologicalGradient3dAlgo.setInputImage( foam );
morphologicalGradient3dAlgo.setKernelRadius( 3 );
morphologicalGradient3dAlgo.setGradientMode( MorphologicalGradient3d::GradientMode::INTERNAL );
morphologicalGradient3dAlgo.setPrecision( MorphologicalGradient3d::Precision::FASTER );
morphologicalGradient3dAlgo.execute();

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

morphological_gradient_3d_algo = imagedev.MorphologicalGradient3d()
morphological_gradient_3d_algo.input_image = foam
morphological_gradient_3d_algo.kernel_radius = 3
morphological_gradient_3d_algo.gradient_mode = imagedev.MorphologicalGradient3d.INTERNAL
morphological_gradient_3d_algo.precision = imagedev.MorphologicalGradient3d.FASTER
morphological_gradient_3d_algo.execute()

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

MorphologicalGradient3d morphologicalGradient3dAlgo = new MorphologicalGradient3d
{
    inputImage = foam,
    kernelRadius = 3,
    gradientMode = MorphologicalGradient3d.GradientMode.INTERNAL,
    precision = MorphologicalGradient3d.Precision.FASTER
};
morphologicalGradient3dAlgo.Execute();

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

Function Examples

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

auto result = morphologicalGradient3d( foam, 3, MorphologicalGradient3d::GradientMode::INTERNAL, MorphologicalGradient3d::Precision::FASTER );

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

result = imagedev.morphological_gradient_3d( foam, 3, imagedev.MorphologicalGradient3d.INTERNAL, imagedev.MorphologicalGradient3d.FASTER )

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

IOLink.ImageView result = Processing.MorphologicalGradient3d( foam, 3, MorphologicalGradient3d.GradientMode.INTERNAL, MorphologicalGradient3d.Precision.FASTER );

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