GradientFilter

GradientFilter[data,r]

gives the magnitude of the gradient of data, computed using discrete derivatives of a Gaussian of sample radius r.

GradientFilter[data,{r,σ}]

uses a Gaussian with standard deviation σ.

GradientFilter[data,{{r1,r2,},}]

uses a Gaussian with radius ri at level i in data.

Details and Options

  • GradientFilter is commonly used in image processing to highlight regions of rapid intensity change using discrete approximations of first Gaussian derivatives in each dimension.
  • The data can be any of the following:
  • listarbitrary-rank numerical array
    tseriestemporal data such as TimeSeries, TemporalData,
    imagearbitrary Image or Image3D object
    audioan Audio object
  • For a single-channel image and for data, the gradient magnitude is the Euclidean norm of the gradient at a pixel position, approximated using discrete derivatives of Gaussians in each dimension.
  • For multichannel images, define the Jacobian matrix to be , where is the gradient for channel . The gradient magnitude is the square root of the largest eigenvalue of .
  • GradientFilter[data,r] is equivalent to GradientFilter[data,{r,r/2}].
  • GradientFilter[data,] by default gives an array, audio object or image of the same dimensions as data.
  • The following options can be specified:
  • MethodAutomaticconvolution kernel
    Padding"Fixed"padding method
    WorkingPrecisionAutomaticthe precision to use
  • The following suboptions can be given to Method:
  • "DerivativeKernel""Bessel"convolution kernel
    "NonMaxSuppression"Falsewhether to use non-maximum suppression
  • Possible settings for "DerivativeKernel" include:
  • "Bessel"standardized Bessel derivative kernel, used for Canny edge detection
    "Gaussian"standardized Gaussian derivative kernel, used for Canny edge detection
    "ShenCastan"first-order derivatives of exponentials
    "Sobel"binomial generalizations of the Sobel edge-detection kernels
    {kernel1,kernel2,}explicit kernels specified for each dimension
  • With setting Padding->None, GradientFilter[data,] normally gives an array, audio object or image smaller than data.
  • GradientFilter[image,] always returns a single-channel image of real type.

Examples

open allclose all

Basic Examples  (3)

Apply gradient filtering to a vector of numbers:

In[1]:=
Click for copyable input
Out[1]=

Gradient filter of a grayscale image:

In[1]:=
Click for copyable input
Out[1]=

Gradient filtering of a 3D image:

In[1]:=
Click for copyable input
Out[1]=

Scope  (10)

Options  (9)

Applications  (4)

Properties & Relations  (4)

Possible Issues  (1)

Neat Examples  (2)

See Also

GradientOrientationFilter  LaplacianGaussianFilter  ImageConvolve  DiscreteDelta  RangeFilter  EdgeDetect  MorphologicalPerimeter  GaussianMatrix  ShenCastanMatrix

Introduced in 2008
(7.0)
| Updated in 2015
(10.1)