ImageDev

Gradient

This group provides first-order derivative operators.

Introduction to Gradient

In the continuous two-dimensional case, the gradient of an image $I(x,y)$ is defined along two orthogonal directions as: $$ G_x(x,y)=\partial I(x,y)/\partial x $$ $$ G_y(x,y)=\partial I(x,y)/\partial y $$ This operator is approximated in the discrete case by differences, as initially introduced by Roberts : $$ \nabla_0(i,j)=I(i,j+1)-I(i,j) $$ $$ \nabla_{90}(i,j)=I(i+1,j)-I(i,j) $$ along horizontal and vertical directions, or: $$ \nabla_{45}(i,j)=I(i+1,j+1)-I(i,j) $$ $$ \nabla_{135}(i,j)=I(i+1,j-1)-I(i,j) $$ along first and second diagonal directions.
These operators are implemented by convolutions with the kernels specified in Figure 1. They enhance edges in the {0,90} or {45,135} directions, respectively.

<b> Figure 1.</b> Roberts Gradient Edge Detectors
Figure 1. Roberts Gradient Edge Detectors

In addition, one can define the magnitude $G$ and orientation $\Theta$ of the gradient, as: $$ G(i,j)=[\nabla_0^2(i,j)+\nabla_{90}^2(i,j)]^{1/2} ~ \mbox{or} ~ [\nabla_{45}^2(i,j)+; \nabla_{135}^2(i,j)]^{1/2} $$ $$ \Theta(i,j)=\arctan[\nabla_{90}(i,j)/\nabla_0(i,j)] ~ \mbox{or} ~ \arctan[\nabla_{135}(i,j)/; \nabla_{45}(i,j)]+\pi/4 $$ Notice: When applying such filters to an image, the output images consist of positive and negative intensities, with an unusual appearance.
The derivative operator behaves as a high frequency filter; that is, it emphasizes details of an image. An immediate drawback of these gradient filters is their sensitivity to noise. When applied to grainy or textured images, the output image consists of high intensities that correspond to both true edges (luminance transitions), and noise (texture, grain aspect, etc.). This sensitivity to noise can be reduced by using larger kernels to approximate the derivative operators.
Typical masks, such as Prewitt or Sobel detectors for 3x3 kernels are given in Figure 2.

<b> Figure 2.</b> Prewitt and Sobel masks
Figure 2. Prewitt and Sobel masks

Another approach is to use morphological operators to estimate the gradient magnitude. We can then define morphological gradients as:
$D_B(I)$ is the result of a dilation with the neighborhood B, and $E_B(I)$ the result of an erosion.
In $R^2$, it can be shown that $\frac{D_B-E_B}{2r}$ tends towards the gradient magnitude when B is a disk whose radius r tends towards 0.

Gradient detection

The output of the above gradients are gray level images, corresponding to emphasized edges in two orthogonal directions. The next step is to identify the pixels on these images that actually correspond to edge points.
A common approach is to mark points of sufficiently large gradient magnitude; for instance, points where the luminance transition is sharp enough. This threshold of the gradient magnitude is illustrated in Figure 3.

<b> Figure 3.</b> Thresholding a gradient
Figure 3. Thresholding a gradient

The overall detection scheme is outlined in Figure 4.

<b> Figure 4.</b> Gradient Computation
Figure 4. Gradient Computation

Remark: The normalization parameter divides the value of the gradient by the sum of the absolute values of the masks, which reduces the noise sensitivity, avoids overflow, but lowers the contrast. Only main edges will appear on the gradient image. If no normalization is performed, be careful with possible overflow, but edges will be much more evident.

Gradient Projections

In the continuous two-dimensional case, for a given pixel $P$ and knowing the gradient components $G_x$ and $G_y$, the projected gradient $G_C$ of $P$ from the center $C$ is defined along the unitary vector $U(u,v)$, as:
$$ G_C=G_x\times u + G_y\times v, ~with~ U(u,v)=\frac{\overrightarrow{P-C} }{\left \| P-C \right \|} $$ In the continuous three-dimensional case, for a given voxel $P$ and knowing the gradient components $G_x$, $G_y$ and $G_z$, the projected gradient $G_C$ of $P$ from the center $C$ is defined along the unitary vector $U(u,v,w)$, as :
$$ G_p=G_x\times u + G_y\times v + G_z\times w, ~with~ U(u,v,w)=\frac{\overrightarrow{P-C} } {\left \| P-C \right \|} $$

<b> (a) </b>
(a)
<b> (b) </b>
(b)
Figure 5. Gradient Projections:
(a) input gray level image with contour (red) or single point (blue) defined projection centers, (b) the projected resulting gradient image (Normal Gradient)

The center C can be defined in different ways: