gives an image corresponding to the magnitude of the gradient of image, computed using discrete derivatives of a Gaussian of pixel radius r.


uses a Gaussian with standard deviation σ.


uses a Gaussian with radii ri etc. in the vertical and horizontal directions.


applies gradient filtering to an array of data.

Details and Options

  • GradientFilter works with arbitrary 2D and 3D images, as well as data arrays of any rank.
  • 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[image,] always returns a single-channel image.
  • GradientFilter[image,r] is equivalent to GradientFilter[image,{r,r/2}].
  • 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[image,] by default gives an image of the same dimensions as image.
  • With a setting Padding->None, GradientFilter[image,] normally gives an image smaller than image.


open allclose all

Basic Examples  (3)

Apply gradient filtering to a vector of numbers:

Click for copyable input

Adjusted gradient filter of a grayscale image:

Click for copyable input

Gradient filtering of a 3D image:

Click for copyable input

Scope  (5)

Options  (4)

Applications  (2)

Possible Issues  (1)

Neat Examples  (2)

See Also

GradientOrientationFilter  LaplacianGaussianFilter  ImageConvolve  DiscreteDelta  RangeFilter  EdgeDetect  MorphologicalPerimeter  GaussianMatrix  ShenCastanMatrix

Introduced in 2008
| Updated in 2015