Main Content

Find gradient magnitude and direction 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. This is similar to the

`'replicate'`

boundary option in`imfilter`

.

The algorithmic approach taken in `imgradient`

for each of the listed
gradient methods is to first compute directional gradients, `Gx`

and
`Gy`

, in the *x* and *y*
directions, respectively. The horizontal (*x*) axis points in the
direction of increasing column subscripts. The vertical (*y*) axis
points in the direction of increasing row subscripts. The gradient magnitude and
direction are then computed from their orthogonal components `Gx`

and
`Gy`

.

`imgradient`

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, for Prewitt, it is 1/6,
and for Roberts it is 1/2.

`imgradientxy`

| `imgradientxyz`

| `imgradient3`

| `edge`

| `fspecial`