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 to detect regions of rapid change in signals and images.
  • 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, the Jacobian matrix is , where is the gradient for channel . Gradient magnitude is the square root of the largest eigenvalue of , returned as a single-channel image.
  • 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 .
  • 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
  • GradientFilter[data,] by default gives an array, audio object or image of the same dimensions as data.
  • With setting Padding->None, GradientFilter[data,] normally gives an array, audio object or image smaller than data.
  • GradientFilter[image,] returns an image of a real type.


open all close all

Basic Examples  (3)

Gradient filter of a grayscale image:

Click for copyable input

Gradient filtering of a 3D image:

Click for copyable input

Apply gradient filtering to a vector of numbers:

Click for copyable input

Scope  (10)

Options  (9)

Applications  (4)

Properties & Relations  (4)

Possible Issues  (1)

Neat Examples  (2)

Introduced in 2008
Updated in 2015