Skip to content

derivate_gaussderivate_gaussDerivateGaussDerivateGaussderivate_gaussderivate_gaussπŸ”—

Short descriptionπŸ”—

derivate_gaussderivate_gaussDerivateGaussDerivateGaussderivate_gaussderivate_gauss β€” Convolve an image with derivatives of the Gaussian.

SignatureπŸ”—

derivate_gauss( image Image, out image DerivGauss, real Sigma, string Component )derivate_gauss( Image : DerivGauss : Sigma, Component : )void DerivateGauss( const HObject& Image, HObject* DerivGauss, const HTuple& Sigma, const HTuple& Component )static void HOperatorSet.DerivateGauss( HObject image, out HObject derivGauss, HTuple sigma, HTuple component )def derivate_gauss( image: HObject, sigma: MaybeSequence[float], component: str ) -> HObject

Herror derivate_gauss( const Hobject Image, Hobject* DerivGauss, double Sigma, const char* Component )

Herror T_derivate_gauss( const Hobject Image, Hobject* DerivGauss, const Htuple Sigma, const Htuple Component )

HImage HImage::DerivateGauss( const HTuple& Sigma, const HString& Component ) const

HImage HImage::DerivateGauss( double Sigma, const HString& Component ) const

HImage HImage::DerivateGauss( double Sigma, const char* Component ) const

HImage HImage::DerivateGauss( double Sigma, const wchar_t* Component ) const (Windows only)

HImage HImage.DerivateGauss( HTuple sigma, string component )

HImage HImage.DerivateGauss( double sigma, string component )

DescriptionπŸ”—

derivate_gaussDerivateGauss convolves an image with the derivatives of a Gaussian and calculates various features derived therefrom. Sigmasigmasigma is the parameter of the Gaussian (i.e., the amount of smoothing). If one value is passed in Sigmasigmasigma the amount of smoothing in the column and row direction is identical. If two values are passed in Sigmasigmasigma the first value specifies the amount of smoothing in the column direction, while the second value specifies the amount of smoothing in the row direction. The possible values for Componentcomponentcomponent are:

  • 'none'"none": Smoothing only.

  • 'x'"x": First derivative along x.

    \[\begin{eqnarray*} g'(x,y) = \frac{\partial g(x,y)}{\partial x} \end{eqnarray*}\]
  • 'y'"y": First derivative along y.

    \[\begin{eqnarray*} g'(x,y) = \frac{\partial g(x,y)}{\partial y} \end{eqnarray*}\]
  • 'gradient'"gradient": Absolute value of the gradient.

    \[\begin{eqnarray*} g'(x,y) = \sqrt{\frac{\partial g(x,y)^2}{\partial x} \frac{\partial g(x,y)^2}{\partial y} } \end{eqnarray*}\]
  • 'gradient_dir'"gradient_dir": Gradient direction in radians.

    \[\begin{eqnarray*} \phi = \textrm{atan2}(\frac{\partial g(x,y)}{\partial y}, \frac{\partial g(x,y)}{\partial x}) \end{eqnarray*}\]
  • 'xx'"xx": Second derivative along x.

    \[\begin{eqnarray*} g'(x,y) = \frac{\partial^2 g(x,y)}{\partial x^2} \end{eqnarray*}\]
  • 'yy'"yy": Second derivative along y.

    \[\begin{eqnarray*} g'(x,y) = \frac{\partial^2 g(x,y)}{\partial y^2} \end{eqnarray*}\]
  • 'xy'"xy": Second derivative along x and y.

    \[\begin{eqnarray*} g'(x,y) = \frac{\partial^2 g(x,y)}{\partial x \partial y} \end{eqnarray*}\]
  • 'xxx'"xxx": Third derivative along x.

    \[\begin{eqnarray*} g'(x,y) = \frac{\partial^3 g(x,y)}{\partial x^3} \end{eqnarray*}\]
  • 'yyy'"yyy": Third derivative along y.

    \[\begin{eqnarray*} g'(x,y) = \frac{\partial^3 g(x,y)}{\partial y^3} \end{eqnarray*}\]
  • 'xxy'"xxy": Third derivative along x, x and y.

    \[\begin{eqnarray*} g'(x,y) = \frac{\partial^3 g(x,y)}{\partial x^2 \partial y} \end{eqnarray*}\]
  • 'xyy'"xyy": Third derivative along x, y and y.

    \[\begin{eqnarray*} g'(x,y) = \frac{\partial^3 g(x,y)}{\partial x \partial y^2} \end{eqnarray*}\]
  • 'det'"det": Determinant of the Hessian matrix:

    \[\begin{eqnarray*} DET = \frac{\partial^2 g(x,y)}{\partial x^2} \frac{\partial^2 g(x,y)}{\partial y^2} - \left(\frac{\partial^2 g(x,y)}{\partial y \partial x}\right)^2 \end{eqnarray*}\]
  • 'laplace'"laplace": Laplace operator (trace of the Hessian matrix):

    \[\begin{eqnarray*} TR = \frac{\partial^2 g(x,y)}{\partial x^2} + \frac{\partial^2 g(x,y)}{\partial y^2} \end{eqnarray*}\]
  • 'mean_curvature'"mean_curvature": Mean curvature \(H\)

    \[\begin{eqnarray*} a & = & (1 + \frac{\partial g(x,y)^2}{\partial x}) \frac{\partial^2 g(x,y)}{\partial y^2} \\ b & = & 2 \frac{\partial g(x,y)}{\partial x} \frac{\partial g(x,y)}{\partial y} \frac{\partial^2 g(x,y)}{\partial y \partial x} \\ c & = & (1 + \frac{\partial g(x,y)^2}{\partial y}) \frac{\partial^2 g(x,y)}{\partial x^2} \\ d & = & (1 + \frac{\partial g(x,y)^2}{\partial x} + \frac{\partial g(x,y)^2}{\partial y})^{\frac{3}{2}}\\ H & = & \frac{a - b + c}{d} \\ H & = & \frac{1}{2} ( \kappa_{min} + \kappa_{max} ) \end{eqnarray*}\]
  • 'gauss_curvature'"gauss_curvature": Gaussian curvature \(K\)

    \[\begin{eqnarray*} K = \frac{DET}{(1 + \frac{\partial g(x,y)^2}{\partial x} + \frac{\partial g(x,y)^2}{\partial y})^2} \end{eqnarray*}\]
  • 'area'"area": Differential Area \(A\)

    \[\begin{eqnarray*} A & = & E G - F^2 \\ E & = & 1 + \frac{\partial g(x,y)}{\partial x}^2 \\ F & = & \frac{\partial g(x,y)}{\partial x} \frac{\partial g(x,y)}{\partial y} \\ G & = & 1 + \frac{\partial g(x,y)}{\partial y}^2 \end{eqnarray*}\]
  • 'eigenvalue1'"eigenvalue1": First eigenvalue

    \[\begin{eqnarray*} a &=& \frac{\frac{\partial^2 g(x,y)}{\partial x^2} + \frac{\partial^2 g(x,y)}{\partial y^2}}{2} \\ \lambda_{1} &=& a + \sqrt{a^2 - (\frac{\partial^2 g(x,y)}{\partial x^2} \frac{\partial^2 g(x,y)}{\partial y^2} - \frac{\partial^2 g(x,y)^2}{\partial y \partial x})} \end{eqnarray*}\]
  • 'eigenvalue2'"eigenvalue2": Second eigenvalue

    \[\begin{eqnarray*} a &=& \frac{\frac{\partial^2 g(x,y)}{\partial x^2} + \frac{\partial^2 g(x,y)}{\partial y^2}}{2} \\ \lambda_{2} &=& a - \sqrt{a^2 - (\frac{\partial^2 g(x,y)}{\partial x^2} \frac{\partial^2 g(x,y)}{\partial y^2} - \frac{\partial^2 g(x,y)^2}{\partial y \partial x})} \end{eqnarray*}\]
  • 'eigenvec_dir'"eigenvec_dir": Direction of the eigenvector corresponding to the first eigenvalue in radians

  • β€˜main1_curvature’ First main curvature

    \[\begin{eqnarray*} \kappa_{max} = H + \sqrt{H^2 - K} \end{eqnarray*}\]
  • β€˜main2_curvature’ Second main curvature

    \[\begin{eqnarray*} \kappa_{min} = H - \sqrt{H^2 - K} \end{eqnarray*}\]
  • 'kitchen_rosenfeld'"kitchen_rosenfeld": Second derivative perpendicular to the gradient

    \[\begin{eqnarray*} k = \frac{\frac{\partial^2 g(x,y)}{\partial x^2} \frac{\partial g(x,y)^2}{\partial y} + \frac{\partial^2 g(x,y)}{\partial y^2} \frac{\partial g(x,y)^2}{\partial x} - 2 \frac{\partial^2 g(x,y)}{\partial y \partial x} \frac{\partial g(x,y)^2}{\partial x} \frac{\partial g(x,y)^2}{\partial y}} {\frac{\partial g(x,y)^2}{\partial x} + \frac{\partial g(x,y)^2}{\partial y}} \end{eqnarray*}\]
  • 'zuniga_haralick'"zuniga_haralick": Normalized second derivative perpendicular to the gradient

    \[\begin{eqnarray*} k = \frac{\frac{\partial^2 g(x,y)}{\partial x^2} \frac{\partial g(x,y)^2}{\partial y} + \frac{\partial^2 g(x,y)}{\partial y^2} \frac{\partial g(x,y)^2}{\partial x} - 2 \frac{\partial^2 g(x,y)}{\partial y \partial x} \frac{\partial g(x,y)^2}{\partial x} \frac{\partial g(x,y)^2}{\partial y}} {{\left(\frac{\partial g(x,y)^2}{\partial x} + \frac{\partial g(x,y)^2}{\partial y}\right)^{\frac{3}{2}}}} \end{eqnarray*}\]
  • '2nd_ddg'"2nd_ddg": Second derivative along the gradient

    \[\begin{eqnarray*} k = \frac{\frac{\partial^2 g(x,y)}{\partial x^2} \frac{\partial g(x,y)^2}{\partial x} + 2\frac{\partial g(x,y)}{\partial x} \frac{\partial g(x,y)}{\partial y} \frac{\partial^2 g(x,y)}{\partial y \partial x} + \frac{\partial^2 g(x,y)}{\partial y^2} \frac{\partial g(x,y)^2}{\partial y}} {\frac{\partial g(x,y)^2}{\partial x} + \frac{\partial g(x,y)^2}{\partial y}} \end{eqnarray*}\]
  • 'de_saint_venant'"de_saint_venant": Second derivative along and perpendicular to the gradient

    \[\begin{eqnarray*} k = \frac{\frac{\partial g(x,y)}{\partial x} \frac{\partial g(x,y)}{\partial y} (\frac{\partial^2 g(x,y)}{\partial x^2} - \frac{\partial^2 g(x,y)}{\partial y^2}) - (\frac{\partial g(x,y)^2}{\partial x} - \frac{\partial g(x,y)^2}{\partial y}) \frac{\partial^2 g(x,y)}{\partial x \partial y}} {\frac{\partial g(x,y)^2}{\partial x} + \frac{\partial g(x,y)^2}{\partial y}} \end{eqnarray*}\]

AttentionπŸ”—

Besides the pure C version there are specific implementations of derivate_gaussDerivateGauss for speed up. Such an optimization is applied in case it is supported by the system and the respective system parameter *_enable is set to 'true'"true", see set_systemSetSystem. The following optimizations are supported (listed according to their priority):

  • using AVX512f instructions ('avx512f_enable'"avx512f_enable")

  • using AVX instructions ('avx_enable'"avx_enable")

  • using SSE2 instructions ('sse2_enable'"sse2_enable")

These implementations are slightly inaccurate compared to the pure C version due to numerical issues. For example, using SSE2 instructions the inaccuracy is in order of magnitude of \(1.0e-5\) for β€˜byte’ images and Componentcomponentcomponent set to 'none'"none", 'x'"x", or 'y'"y".

In case accuracy is preferred over performance, set all corresponding system parameter to 'false'"false" (using set_systemSetSystem) before calling derivate_gaussDerivateGauss. This way derivate_gaussDerivateGauss does not use the accelerations. Do not forget to set the parameter back to 'true'"true" afterwards.

derivate_gaussDerivateGauss is only executed on an OpenCL device if Sigmasigmasigma induces a filter width respectively height of up to 129 pixels. This corresponds to a Sigmasigmasigma of less than \(20.7\) for Componentcomponentcomponent = 'none'"none". The OpenCL implementation is slightly inaccurate compared to the pure C version due to numerical issues.

Note that filter operators may return unexpected results if an image with a reduced domain is used as input. Please refer to the chapter Filters.

Execution informationπŸ”—

Execution information
  • Supports OpenCL compute devices.

  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on tuple level.

  • Automatically parallelized on channel level.

  • Automatically parallelized on domain level.

ParametersπŸ”—

Imageimageimage (input_object) (multichannel-)image(-array) β†’ object (byte* / direction* / cyclic* / int1* / int2* / uint2* / int4* / real*)object (byte* / direction* / cyclic* / int1* / int2* / uint2* / int4* / real*)HObject (byte* / direction* / cyclic* / int1* / int2* / uint2* / int4* / real*)HImage (byte* / direction* / cyclic* / int1* / int2* / uint2* / int4* / real*)HObject (byte* / direction* / cyclic* / int1* / int2* / uint2* / int4* / real*)Hobject (byte* / direction* / cyclic* / int1* / int2* / uint2* / int4* / real*) *allowed for compute devices

Input images.

DerivGaussderivGaussderiv_gauss (output_object) (multichannel-)image(-array) β†’ object (real)object (real)HObject (real)HImage (real)HObject (real)Hobject * (real)

Filtered result images.

Sigmasigmasigma (input_control) real(-array) β†’ (real)(real)HTuple (double)HTuple (double)MaybeSequence[float]Htuple (double)

Sigma of the Gaussian.

Default: 1.01.0
Suggested values: 0.7, 1.0, 1.5, 2.0, 3.0, 4.0, 5.00.7, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0
Value range: 0.01 ≀ Sigma ≀ 50.0
Minimum increment: 0.01
Recommended increment: 0.1

Componentcomponentcomponent (input_control) string β†’ (string)(string)HTuple (HString)HTuple (string)strHtuple (char*)

Derivative or feature to be calculated.

Default: 'x'"x"
List of values: '2nd_ddg', 'area', 'de_saint_venant', 'det', 'eigenvalue1', 'eigenvalue2', 'eigenvec_dir', 'gauss_curvature', 'gradient', 'gradient_dir', 'kitchen_rosenfeld', 'laplace', 'main1_curvature', 'main2_curvature', 'mean_curvature', 'none', 'x', 'xx', 'xxx', 'xxy', 'xy', 'xyy', 'y', 'yy', 'yyy', 'zuniga_haralick'"2nd_ddg", "area", "de_saint_venant", "det", "eigenvalue1", "eigenvalue2", "eigenvec_dir", "gauss_curvature", "gradient", "gradient_dir", "kitchen_rosenfeld", "laplace", "main1_curvature", "main2_curvature", "mean_curvature", "none", "x", "xx", "xxx", "xxy", "xy", "xyy", "y", "yy", "yyy", "zuniga_haralick"
List of values (for compute devices): 'gradient', 'gradient_dir', 'laplace', 'none', 'x', 'xx', 'xxx', 'xxy', 'xy', 'xyy', 'y', 'yy', 'yyy'"gradient", "gradient_dir", "laplace", "none", "x", "xx", "xxx", "xxy", "xy", "xyy", "y", "yy", "yyy"

ExampleπŸ”—

(C)

read_image(&Image,"mreut")\;
derivate_gauss(Image,&Gauss,3.0,"x")\;
zero_crossing(Gauss,&ZeroCrossings)\;

Combinations with other operatorsπŸ”—

Combinations

Possible successors

zero_crossingZeroCrossing, dual_thresholdDualThreshold

Alternatives

laplaceLaplace, laplace_of_gaussLaplaceOfGauss, binomial_filterBinomialFilter, gauss_filterGaussFilter, smooth_imageSmoothImage, isotropic_diffusionIsotropicDiffusion

See also

zero_crossingZeroCrossing, dual_thresholdDualThreshold

ModuleπŸ”—

Foundation