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


uses a Gaussian with standard deviation σ.


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
  • GradientFilter[data,r] uses standard deviation .
  • 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,] 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 a real type.


open allclose all

Basic Examples  (3)

Apply gradient filtering to a vector of numbers:

Click for copyable input

Gradient filter of a grayscale image:

Click for copyable input

Gradient filtering of a 3D image:

Click for copyable input

Scope  (10)

Options  (9)

Applications  (4)

Properties & Relations  (4)

Possible Issues  (1)

Neat Examples  (2)

See Also

GradientOrientationFilter  GaussianFilter  LaplacianGaussianFilter  ImageConvolve  DiscreteDelta  RangeFilter  EdgeDetect  MorphologicalPerimeter  GaussianMatrix  ShenCastanMatrix

Introduced in 2008
| Updated in 2015