GradientOperator3d
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:
For color images the same algorithm is iterated on each color channel.
The following algorithms are provided to extract the edges of an image:
[1] R.Deriche. "Using Canny's criteria to derive a recursively implemented optimal edge detector". International Journal of Computer Vision, vol.1, no 2, pp. 167-187, Jun. 1987.
[2] J.F.Canny. "A computational approach to edge detection." IEEE Transactions on Pattern Analysis and Machine Intelligence, vol.8, No 6, pp. 679-698, Nov. 1986.
See also
Access to parameter description
For an introduction:
- section Edge Detection
- section Gradient
- section Images Filters
For color images the same algorithm is iterated on each color channel.
The following algorithms are provided to extract the edges of an image:
- Canny-Deriche: It performs a recursive gradient computation with an IIR (Infinite Impulse Response) filter by derivating the Deriche [1] smoothing filter which has the three-dimensional form: $$ f(x,y,z)=b^3(\alpha|x|+1)e^{-\alpha|x|}\cdot(\alpha|y|+1)e^{-\alpha|y|}\cdot(\alpha|z|+1)e^{-\alpha|z|} ~~where~~b=\frac{\alpha}{4} $$
- Canny: It is similar to Canny-Deriche but uses a FIR (finite impulse response) filter [2]. It performs an approximation to get the Canny-Deriche in the X, Y, and Z directions using a convolution kernel 7x5x5 for X, 5x7x5 for Y and 5x5x7 for Z. The result is nearly the same as Canny-Deriche but the process is much faster.
- Gaussian: It performs a convolution with the derivatives of a Gaussian function along each image axis.
- Sobel: It performs a convolution with the Sobel Kernel. This kernel is the 3D generalization of the Sobel kernel described in GradientOperator2d.
- Prewitt: It performs a convolution with the Prewitt Kernel. This kernel is the 3D generalization of the Prewitt kernel described in GradientOperator2d.
- The output data type is determined by applying the Basic rules defined for arithmetic operations.
- To limit overflows some normalizations are applied with most of the proposed operators by dividing the output gray levels by the sum of absolute values of the kernel coefficients.
- The Prewitt and Sobel operators do not apply normalizations and are thus inclined to produce overflows.
- By default, the maximum component of each directional gradient is computed. Depending on the selected operator, other output can be selected such as the Euclidean norm or the gradient components.
- The smoothing factor has a totally different meaning depending on the selected gradient operator. It represents a smoothing percentage with Canny-Deriche, a standard-deviation with the Gaussian and is ignored with Canny, Sobel and Prewitt.
[1] R.Deriche. "Using Canny's criteria to derive a recursively implemented optimal edge detector". International Journal of Computer Vision, vol.1, no 2, pp. 167-187, Jun. 1987.
[2] J.F.Canny. "A computational approach to edge detection." IEEE Transactions on Pattern Analysis and Machine Intelligence, vol.8, No 6, pp. 679-698, Nov. 1986.
See also
Function Syntax
This function returns a GradientOperator3dOutput structure containing the outputImageX, outputImageY, outputImageZ and outputAmplitudeImage output parameters.
// Output structure. struct GradientOperator3dOutput { std::shared_ptr< iolink::ImageView > outputImageX; std::shared_ptr< iolink::ImageView > outputImageY; std::shared_ptr< iolink::ImageView > outputImageZ; std::shared_ptr< iolink::ImageView > outputAmplitudeImage; }; // Function prototype. GradientOperator3dOutput gradientOperator3d( std::shared_ptr< iolink::ImageView > inputImage, GradientOperator3d::GradientOperator gradientOperator, GradientOperator3d::GradientMode gradientMode, double smoothingFactor, std::shared_ptr< iolink::ImageView > outputImageX = NULL, std::shared_ptr< iolink::ImageView > outputImageY = NULL, std::shared_ptr< iolink::ImageView > outputImageZ = NULL, std::shared_ptr< iolink::ImageView > outputAmplitudeImage = NULL );
This function returns a tuple containing the output_image_x, output_image_y, output_image_z and output_amplitude_image output parameters.
// Function prototype. gradient_operator_3d( input_image, gradient_operator = GradientOperator3d.GradientOperator.CANNY_DERICHE, gradient_mode = GradientOperator3d.GradientMode.AMPLITUDE_MAXIMUM, smoothing_factor = 60, output_image_x = None, output_image_y = None, output_image_z = None, output_amplitude_image = None )
This function returns a GradientOperator3dOutput structure containing the outputImageX, outputImageY, outputImageZ and outputAmplitudeImage output parameters.
/// Output structure of the GradientOperator3d function. public struct GradientOperator3dOutput { public IOLink.ImageView outputImageX; public IOLink.ImageView outputImageY; public IOLink.ImageView outputImageZ; public IOLink.ImageView outputAmplitudeImage; }; // Function prototype. public static GradientOperator3dOutput GradientOperator3d( IOLink.ImageView inputImage, GradientOperator3d.GradientOperator gradientOperator = ImageDev.GradientOperator3d.GradientOperator.CANNY_DERICHE, GradientOperator3d.GradientMode gradientMode = ImageDev.GradientOperator3d.GradientMode.AMPLITUDE_MAXIMUM, double smoothingFactor = 60, IOLink.ImageView outputImageX = null, IOLink.ImageView outputImageY = null, IOLink.ImageView outputImageZ = null, IOLink.ImageView outputAmplitudeImage = null );
Class Syntax
Parameters
Class Name | GradientOperator3d |
---|
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 | CANNY_DERICHE | ||||||||||||
gradientMode |
Select an output mode.
|
Enumeration | AMPLITUDE_MAXIMUM | ||||||||||||
smoothingFactor |
The smoothing factor defines the gradient sharpness. It is only used with Canny Deriche, and Gaussian operators. It has a totally different meaning depending on the selected gradient operator. Its value must be between 0 and 100.
|
Float64 | ]0, 100] | 60 | |||||||||||
outputImageX |
The X-gradient output image. | Image | nullptr | ||||||||||||
outputImageY |
The Y-gradient output image. | Image | nullptr | ||||||||||||
outputImageZ |
The Z-gradient output image. | Image | nullptr | ||||||||||||
outputAmplitudeImage |
The gradient amplitude output image. | Image | nullptr |
Object Examples
auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" ); GradientOperator3d gradientOperator3dAlgo; gradientOperator3dAlgo.setInputImage( foam ); gradientOperator3dAlgo.setGradientOperator( GradientOperator3d::GradientOperator::CANNY_DERICHE ); gradientOperator3dAlgo.setGradientMode( GradientOperator3d::GradientMode::AMPLITUDE_MAXIMUM ); gradientOperator3dAlgo.setSmoothingFactor( 60.0 ); gradientOperator3dAlgo.execute(); std::cout << "outputImageX:" << gradientOperator3dAlgo.outputImageX()->toString(); std::cout << "outputImageY:" << gradientOperator3dAlgo.outputImageY()->toString(); std::cout << "outputImageZ:" << gradientOperator3dAlgo.outputImageZ()->toString(); std::cout << "outputAmplitudeImage:" << gradientOperator3dAlgo.outputAmplitudeImage()->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip")) gradient_operator_3d_algo = imagedev.GradientOperator3d() gradient_operator_3d_algo.input_image = foam gradient_operator_3d_algo.gradient_operator = imagedev.GradientOperator3d.CANNY_DERICHE gradient_operator_3d_algo.gradient_mode = imagedev.GradientOperator3d.AMPLITUDE_MAXIMUM gradient_operator_3d_algo.smoothing_factor = 60.0 gradient_operator_3d_algo.execute() print( "output_image_x:", str( gradient_operator_3d_algo.output_image_x ) ); print( "output_image_y:", str( gradient_operator_3d_algo.output_image_y ) ); print( "output_image_z:", str( gradient_operator_3d_algo.output_image_z ) ); print( "output_amplitude_image:", str( gradient_operator_3d_algo.output_amplitude_image ) );
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" ); GradientOperator3d gradientOperator3dAlgo = new GradientOperator3d { inputImage = foam, gradientOperator = GradientOperator3d.GradientOperator.CANNY_DERICHE, gradientMode = GradientOperator3d.GradientMode.AMPLITUDE_MAXIMUM, smoothingFactor = 60.0 }; gradientOperator3dAlgo.Execute(); Console.WriteLine( "outputImageX:" + gradientOperator3dAlgo.outputImageX.ToString() ); Console.WriteLine( "outputImageY:" + gradientOperator3dAlgo.outputImageY.ToString() ); Console.WriteLine( "outputImageZ:" + gradientOperator3dAlgo.outputImageZ.ToString() ); Console.WriteLine( "outputAmplitudeImage:" + gradientOperator3dAlgo.outputAmplitudeImage.ToString() );
Function Examples
auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" ); auto result = gradientOperator3d( foam, GradientOperator3d::GradientOperator::CANNY_DERICHE, GradientOperator3d::GradientMode::AMPLITUDE_MAXIMUM, 60.0 ); std::cout << "outputImageX:" << result.outputImageX->toString(); std::cout << "outputImageY:" << result.outputImageY->toString(); std::cout << "outputImageZ:" << result.outputImageZ->toString(); std::cout << "outputAmplitudeImage:" << result.outputAmplitudeImage->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip")) result_output_image_x, result_output_image_y, result_output_image_z, result_output_amplitude_image = imagedev.gradient_operator_3d( foam, imagedev.GradientOperator3d.CANNY_DERICHE, imagedev.GradientOperator3d.AMPLITUDE_MAXIMUM, 60.0 ) 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 ) ); print( "output_amplitude_image:", str( result_output_amplitude_image ) );
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" ); Processing.GradientOperator3dOutput result = Processing.GradientOperator3d( foam, GradientOperator3d.GradientOperator.CANNY_DERICHE, GradientOperator3d.GradientMode.AMPLITUDE_MAXIMUM, 60.0 ); Console.WriteLine( "outputImageX:" + result.outputImageX.ToString() ); Console.WriteLine( "outputImageY:" + result.outputImageY.ToString() ); Console.WriteLine( "outputImageZ:" + result.outputImageZ.ToString() ); Console.WriteLine( "outputAmplitudeImage:" + result.outputAmplitudeImage.ToString() );