Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Directional gradients of an image

```
[Gx,Gy]
= imgradientxy(I)
```

```
[Gx,Gy]
= imgradientxy(I,method)
```

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`