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:
The following algorithms are proposed to extract the edges of an image:
See also
Access to parameter description
For an introduction:
- section Edge Detection
- section Gradient
- section Images Filters
The following algorithms are proposed to extract the edges of an image:
- Gaussian: It performs a convolution with the derivatives of a Gaussian function along each image axis.
- Sobel: It performs a convolution with the normalized Sobel Kernel.
- Prewitt: It performs a convolution with the normalized Prewitt Kernel:
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 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
inputImage |
The input image. | Image | Binary, Label, Grayscale or Multispectral | nullptr | ||||||||
![]() |
gradientOperator |
The gradient operator to apply.
|
Enumeration | GAUSSIAN | |||||||||
![]() |
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} | ||||||||
![]() |
filterMode |
The gradient operator to apply.
|
Enumeration | RECURSIVE | |||||||||
![]() |
outputType |
The output image type to provide.
|
Enumeration | FLOAT_32_BIT | |||||||||
![]() |
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 | |||||||||
![]() |
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 | |||||||||
![]() |
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_image |
The input image. | image | Binary, Label, Grayscale or Multispectral | None | ||||||||
![]() |
gradient_operator |
The gradient operator to apply.
|
enumeration | GAUSSIAN | |||||||||
![]() |
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] | ||||||||
![]() |
filter_mode |
The gradient operator to apply.
|
enumeration | RECURSIVE | |||||||||
![]() |
output_type |
The output image type to provide.
|
enumeration | FLOAT_32_BIT | |||||||||
![]() |
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_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_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 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
inputImage |
The input image. | Image | Binary, Label, Grayscale or Multispectral | null | ||||||||
![]() |
gradientOperator |
The gradient operator to apply.
|
Enumeration | GAUSSIAN | |||||||||
![]() |
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} | ||||||||
![]() |
filterMode |
The gradient operator to apply.
|
Enumeration | RECURSIVE | |||||||||
![]() |
outputType |
The output image type to provide.
|
Enumeration | FLOAT_32_BIT | |||||||||
![]() |
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 | |||||||||
![]() |
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 | |||||||||
![]() |
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() );

