[Gx,Gy]
= imgradientxy(I) returns the directional
gradients, Gx and Gy, the
same size as the input image I.

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.

[gpuarrayGx,gpuarrayGy]
= imgradientxy(gpuarrayI,___) performs
the operation on a GPU. The input image and the return values are
gpuArrays. This syntax requires the Parallel Computing Toolbox™

Read image and return directional gradients, Gx and Gx,
as well as gradient magnitude and direction, Gmag and Gdir,
utilizing default Sobel gradient operator.

I = imread('coins.png');
[Gx, Gy] = imgradientxy(I);
[Gmag, Gdir] = imgradient(Gx, Gy);
figure; imshowpair(Gmag, Gdir, 'montage'); axis off;
title('Gradient Magnitude, Gmag (left), and Gradient Direction, Gdir (right), using Sobel method')
figure; imshowpair(Gx, Gy, 'montage'); axis off;
title('Directional Gradients, Gx and Gy, using Sobel method')

Read image and return directional gradients, Gx and Gx,
as well as gradient magnitude and direction, Gmag and Gdir,
utilizing default Sobel gradient operator.

Directional gradient along the x-axis, returned
as non-sparse matrix equal in size to image I.
The x-axis points in the direction of increasing
column subscripts. The output matrices are of class double,
unless the input image is of class single, in which
case they are of class single.

When the input image I is a gpuArray, Gx is
a gpuArray.

Directional gradient along the x-axis, returned
as non-sparse gpuArray equal in size to image I.
The x-axis points in the direction of increasing
column subscripts. The output matrices are of class double,
unless the input image is of class single, in which
case they are of class single.

Directional gradients along the y-axis, returned
as non-sparse matrix equal in size to image I.
The y-axis points in the direction of increasing
row subscripts. The output matrices are of class double,
unless the input image is of class single, in which
case they are of class single.

Directional gradients along the y-axis, returned
as non-sparse gpuArray equal in size to image I.
The y-axis points in the direction of increasing
row subscripts. The output matrices are of class double,
unless the input image is of class single, in which
case they are of class single.

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.