Main Content

Find directional gradients of 2-D image

When applying the gradient operator at the boundaries of the image, values outside the bounds of the image are assumed to equal the nearest image border value.

The algorithmic approach is to compute directional gradients
with respect to the *x*-axis and *y*-axis.
The *x*-axis is defined along the columns going right
and the *y*-axis is defined along the rows going
down.

`imgradientxy`

does not normalize the gradient
output. If the range of the gradient output image has to match the
range of the input image, consider normalizing the gradient image,
depending on the `method`

argument used. For example,
with a Sobel kernel, the normalization factor is 1/8, and for Prewitt,
it is 1/6.

`edge`

| `fspecial`

| `imgradient`

| `imgradient3`

| `imgradientxyz`