Function File: [gradX, gradY] = imgradientxy (img)
Function File: [gradX, gradY] = imgradientxy (img, method)

Compute the x and y gradients of an image using various methods.

The first input img is the gray scale image to compute the edges on. The second input method controls the method used to calculate the gradients.

The first output gradX returns the gradient in the x direction. The second output gradY returns the gradient in the y direction.

The method input argument can be any of the following strings:

"sobel" (default)

Calculates the gradient using the Sobel approximation to the derivatives.

"prewitt"

Calculates the gradient using the Prewitt approximation to the derivatives. This method works just like Sobel except a different approximation of the gradient is used.

"central" or "centraldifference"

Calculates the gradient using the central difference approximation to the derivatives: (x(i-1) - x(i+1))/2.

"intermediate" or "intermediatedifference"

Calculates the gradient in using the intermediate difference approximation to the derivatives: x(i) - x(i+1).

See also: edge, imgradient.

Package: image