ImageDev

GradientVector3d

Provides different algorithms to perform an edge detection based on the first derivative of a three-dimensional image.

Access to parameter description

For an introduction: GradientVector3d computes a first order derivative in each image axis direction.

The following algorithms are proposed to extract the edges of an image:
See also

Function Syntax

This function returns a GradientVector3dOutput structure containing outputImageX, outputImageY and outputImageZ.
// Output structure of the gradientVector3d function.
struct GradientVector3dOutput
{
    /// The gradient output image in X direction.
    std::shared_ptr< iolink::ImageView > outputImageX;
    /// The gradient output image in Y direction.
    std::shared_ptr< iolink::ImageView > outputImageY;
    /// The gradient output image in Z direction.
    std::shared_ptr< iolink::ImageView > outputImageZ;
};

// Function prototype
GradientVector3dOutput gradientVector3d( std::shared_ptr< iolink::ImageView > inputImage, GradientVector3d::GradientOperator gradientOperator, iolink::Vector3d standardDeviation, GradientVector3d::FilterMode filterMode, GradientVector3d::OutputType outputType, std::shared_ptr< iolink::ImageView > outputImageX = NULL, std::shared_ptr< iolink::ImageView > outputImageY = NULL, std::shared_ptr< iolink::ImageView > outputImageZ = NULL );
This function returns a tuple containing output_image_x, output_image_y and output_image_z.
// Function prototype.
gradient_vector_3d( input_image,
                    gradient_operator = GradientVector3d.GradientOperator.GAUSSIAN,
                    standard_deviation = [1, 1, 1],
                    filter_mode = GradientVector3d.FilterMode.RECURSIVE,
                    output_type = GradientVector3d.OutputType.FLOAT_32_BIT,
                    output_image_x = None,
                    output_image_y = None,
                    output_image_z = None )
This function returns a GradientVector3dOutput structure containing outputImageX, outputImageY and outputImageZ.
/// Output structure of the GradientVector3d function.
public struct GradientVector3dOutput
{
    /// The gradient output image in X direction.
    public IOLink.ImageView outputImageX;
    /// The gradient output image in Y direction.
    public IOLink.ImageView outputImageY;
    /// The gradient output image in Z direction.
    public IOLink.ImageView outputImageZ;
};

// Function prototype.
public static GradientVector3dOutput
GradientVector3d( IOLink.ImageView inputImage,
                  GradientVector3d.GradientOperator gradientOperator = ImageDev.GradientVector3d.GradientOperator.GAUSSIAN,
                  double[] standardDeviation = null,
                  GradientVector3d.FilterMode filterMode = ImageDev.GradientVector3d.FilterMode.RECURSIVE,
                  GradientVector3d.OutputType outputType = ImageDev.GradientVector3d.OutputType.FLOAT_32_BIT,
                  IOLink.ImageView outputImageX = null,
                  IOLink.ImageView outputImageY = null,
                  IOLink.ImageView outputImageZ = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
gradientOperator
The gradient operator to apply.
GAUSSIAN The gradient is computed by convolution with the derivative of a Gaussian filter.
SOBEL The gradient is computed using the Sobel algorithm.
PREWITT The gradient is computed using the Prewitt algorithm.
Enumeration GAUSSIAN
input
standardDeviation
The standard deviation of the gaussian operator defines the gradient sharpness. Low values provide sharp gradient.
This parameter is ignored with the Sobel and Prewitt gradient operators.
Vector3d >=0.1 {1.f, 1.f, 1.f}
input
filterMode
The gradient operator to apply.
FINITE This mode uses a Finite Impulse Response algorithm on the X, Y and Z directions. This mode is faster for small standard deviation values. The kernel size value is four times the standard deviation and cannot be smaller than 5.
RECURSIVE This mode uses an Infinite Impulse Response algorithm on the X, Y and Z directions. The computation time is constant with this implementation. This mode is more precise for computing the Gaussian filter.
Enumeration RECURSIVE
input
outputType
The output image type to provide.
SIGNED_INTEGER_8_BIT The output image type is forced to 8-bit signed integer.
SIGNED_INTEGER_16_BIT The output image type is forced to 16-bit signed integer.
SIGNED_INTEGER_32_BIT The output image type is forced to 32-bit signed integer.
FLOAT_32_BIT The output image type is forced to 32-bit float.
Enumeration FLOAT_32_BIT
output
outputImageX
The gradient output image in X direction.
Dimensions, calibration, and interpretation of the output image are forced to the same values as the input.
Image nullptr
output
outputImageY
The gradient output image in Y direction.
Dimensions, calibration, and interpretation of the output image are forced to the same values as the input.
Image nullptr
output
outputImageZ
The gradient output image in Z direction.
Dimensions, calibration, and interpretation of the output image are forced to the same values as the input.
Image nullptr
Parameter Name Description Type Supported Values Default Value
input
input_image
The input image. image Binary, Label, Grayscale or Multispectral None
input
gradient_operator
The gradient operator to apply.
GAUSSIAN The gradient is computed by convolution with the derivative of a Gaussian filter.
SOBEL The gradient is computed using the Sobel algorithm.
PREWITT The gradient is computed using the Prewitt algorithm.
enumeration GAUSSIAN
input
standard_deviation
The standard deviation of the gaussian operator defines the gradient sharpness. Low values provide sharp gradient.
This parameter is ignored with the Sobel and Prewitt gradient operators.
vector3d >=0.1 [1, 1, 1]
input
filter_mode
The gradient operator to apply.
FINITE This mode uses a Finite Impulse Response algorithm on the X, Y and Z directions. This mode is faster for small standard deviation values. The kernel size value is four times the standard deviation and cannot be smaller than 5.
RECURSIVE This mode uses an Infinite Impulse Response algorithm on the X, Y and Z directions. The computation time is constant with this implementation. This mode is more precise for computing the Gaussian filter.
enumeration RECURSIVE
input
output_type
The output image type to provide.
SIGNED_INTEGER_8_BIT The output image type is forced to 8-bit signed integer.
SIGNED_INTEGER_16_BIT The output image type is forced to 16-bit signed integer.
SIGNED_INTEGER_32_BIT The output image type is forced to 32-bit signed integer.
FLOAT_32_BIT The output image type is forced to 32-bit float.
enumeration FLOAT_32_BIT
output
output_image_x
The gradient output image in X direction.
Dimensions, calibration, and interpretation of the output image are forced to the same values as the input.
image None
output
output_image_y
The gradient output image in Y direction.
Dimensions, calibration, and interpretation of the output image are forced to the same values as the input.
image None
output
output_image_z
The gradient output image in Z direction.
Dimensions, calibration, and interpretation of the output image are forced to the same values as the input.
image None
Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral null
input
gradientOperator
The gradient operator to apply.
GAUSSIAN The gradient is computed by convolution with the derivative of a Gaussian filter.
SOBEL The gradient is computed using the Sobel algorithm.
PREWITT The gradient is computed using the Prewitt algorithm.
Enumeration GAUSSIAN
input
standardDeviation
The standard deviation of the gaussian operator defines the gradient sharpness. Low values provide sharp gradient.
This parameter is ignored with the Sobel and Prewitt gradient operators.
Vector3d >=0.1 {1f, 1f, 1f}
input
filterMode
The gradient operator to apply.
FINITE This mode uses a Finite Impulse Response algorithm on the X, Y and Z directions. This mode is faster for small standard deviation values. The kernel size value is four times the standard deviation and cannot be smaller than 5.
RECURSIVE This mode uses an Infinite Impulse Response algorithm on the X, Y and Z directions. The computation time is constant with this implementation. This mode is more precise for computing the Gaussian filter.
Enumeration RECURSIVE
input
outputType
The output image type to provide.
SIGNED_INTEGER_8_BIT The output image type is forced to 8-bit signed integer.
SIGNED_INTEGER_16_BIT The output image type is forced to 16-bit signed integer.
SIGNED_INTEGER_32_BIT The output image type is forced to 32-bit signed integer.
FLOAT_32_BIT The output image type is forced to 32-bit float.
Enumeration FLOAT_32_BIT
output
outputImageX
The gradient output image in X direction.
Dimensions, calibration, and interpretation of the output image are forced to the same values as the input.
Image null
output
outputImageY
The gradient output image in Y direction.
Dimensions, calibration, and interpretation of the output image are forced to the same values as the input.
Image null
output
outputImageZ
The gradient output image in Z direction.
Dimensions, calibration, and interpretation of the output image are forced to the same values as the input.
Image null

Object Examples

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

GradientVector3d gradientVector3dAlgo;
gradientVector3dAlgo.setInputImage( polystyrene );
gradientVector3dAlgo.setGradientOperator( GradientVector3d::GradientOperator::GAUSSIAN );
gradientVector3dAlgo.setStandardDeviation( {1, 1, 1} );
gradientVector3dAlgo.setFilterMode( GradientVector3d::FilterMode::RECURSIVE );
gradientVector3dAlgo.setOutputType( GradientVector3d::OutputType::FLOAT_32_BIT );
gradientVector3dAlgo.execute();

std::cout << "outputImageX:" << gradientVector3dAlgo.outputImageX()->toString();
std::cout << "outputImageY:" << gradientVector3dAlgo.outputImageY()->toString();
std::cout << "outputImageZ:" << gradientVector3dAlgo.outputImageZ()->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

gradient_vector_3d_algo = imagedev.GradientVector3d()
gradient_vector_3d_algo.input_image = polystyrene
gradient_vector_3d_algo.gradient_operator = imagedev.GradientVector3d.GAUSSIAN
gradient_vector_3d_algo.standard_deviation = [1, 1, 1]
gradient_vector_3d_algo.filter_mode = imagedev.GradientVector3d.RECURSIVE
gradient_vector_3d_algo.output_type = imagedev.GradientVector3d.FLOAT_32_BIT
gradient_vector_3d_algo.execute()

print( "output_image_x:", str( gradient_vector_3d_algo.output_image_x ) )
print( "output_image_y:", str( gradient_vector_3d_algo.output_image_y ) )
print( "output_image_z:", str( gradient_vector_3d_algo.output_image_z ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

GradientVector3d gradientVector3dAlgo = new GradientVector3d
{
    inputImage = polystyrene,
    gradientOperator = GradientVector3d.GradientOperator.GAUSSIAN,
    standardDeviation = new double[]{1, 1, 1},
    filterMode = GradientVector3d.FilterMode.RECURSIVE,
    outputType = GradientVector3d.OutputType.FLOAT_32_BIT
};
gradientVector3dAlgo.Execute();

Console.WriteLine( "outputImageX:" + gradientVector3dAlgo.outputImageX.ToString() );
Console.WriteLine( "outputImageY:" + gradientVector3dAlgo.outputImageY.ToString() );
Console.WriteLine( "outputImageZ:" + gradientVector3dAlgo.outputImageZ.ToString() );

Function Examples

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

auto result = gradientVector3d( polystyrene, GradientVector3d::GradientOperator::GAUSSIAN, {1, 1, 1}, GradientVector3d::FilterMode::RECURSIVE, GradientVector3d::OutputType::FLOAT_32_BIT );

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

result_output_image_x, result_output_image_y, result_output_image_z = imagedev.gradient_vector_3d( polystyrene, imagedev.GradientVector3d.GAUSSIAN, [1, 1, 1], imagedev.GradientVector3d.RECURSIVE, imagedev.GradientVector3d.FLOAT_32_BIT )

print( "output_image_x:", str( result_output_image_x ) )
print( "output_image_y:", str( result_output_image_y ) )
print( "output_image_z:", str( result_output_image_z ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

Processing.GradientVector3dOutput result = Processing.GradientVector3d( polystyrene, GradientVector3d.GradientOperator.GAUSSIAN, new double[]{1, 1, 1}, GradientVector3d.FilterMode.RECURSIVE, GradientVector3d.OutputType.FLOAT_32_BIT );

Console.WriteLine( "outputImageX:" + result.outputImageX.ToString() );
Console.WriteLine( "outputImageY:" + result.outputImageY.ToString() );
Console.WriteLine( "outputImageZ:" + result.outputImageZ.ToString() );