<< >> Up Title Contents Index

Derivative-based Operations

Just as smoothing is a fundamental operation in image processing so is the ability to take one or more spatial derivatives of the image. The fundamental problem is that, according to the mathematical definition of a derivative, this cannot be done. A digitized image is not a continuous function a(x,y) of the spatial variables but rather a discrete function a[m,n] of the integer spatial coordinates. As a result the algorithms we will present can only be seen as approximations to the true spatial derivatives of the original spatially-continuous image.

Further, as we can see from the Fourier property in eq. , taking a derivative multiplies the signal spectrum by either u or v. This means that high frequency noise will be emphasized in the resulting image. The general solution to this problem is to combine the derivative operation with one that suppresses high frequency noise, in short, smoothing in combination with the desired derivative operation.

First Derivatives

As an image is a function of two (or more) variables it is necessary to define the direction in which the derivative is taken. For the two-dimensional case we have the horizontal direction, the vertical direction, or an arbitrary direction which can be considered as a combination of the two. If we use hx to denote a horizontal derivative filter (matrix), hy to denote a vertical derivative filter (matrix), and h to denote the arbitrary angle derivative filter (matrix), then:

* Gradient filters - It is also possible to generate a vector derivative description as the gradient, a[m,n], of an image:

where are unit vectors in the horizontal and vertical direction, respectively. This leads to two descriptions:

Gradient magnitude -

and

Gradient direction -

The gradient magnitude is sometimes approximated by:

Approx. Gradient magnitude -

The final results of these calculations depend strongly on the choices of hx and hy. A number of possible choices for (hx, hy) will now be described.

* Basic derivative filters - These filters are specified by:

where "t" denotes matrix transpose. These two filters differ significantly in their Fourier magnitude and Fourier phase characteristics. For the frequency range 0 <= <= , these are given by:

The second form (ii) gives suppression of high frequency terms ( ~ ) while the first form (i) does not. The first form leads to a phase shift; the second form does not.

* Prewitt gradient filters - These filters are specified by:

Both hx and hy are separable. Beyond the computational implications are the implications for the analysis of the filter. Each filter takes the derivative in one direction using eq. ii and smoothes in the orthogonal direction using a one-dimensional version of a uniform filter as described in Section 9.4.1.

* Sobel gradient filters - These filters are specified by:

Again, hx and hy are separable. Each filter takes the derivative in one direction using eq. ii and smoothes in the orthogonal direction using a one-dimensional version of a triangular filter as described in Section 9.4.1.

* Alternative gradient filters - The variety of techniques available from one-dimensional signal processing for the design of digital filters offers us powerful tools for designing one-dimensional versions of hx and hy. Using the Parks-McClellan filter design algorithm, for example, we can choose the frequency bands where we want the derivative to be taken and the frequency bands where we want the noise to be suppressed. The algorithm will then produce a real, odd filter with a minimum length that meets the specifications.

As an example, if we want a filter that has derivative characteristics in a passband (with weight 1.0) in the frequency range 0.0 <= <= 0.3 and a stopband (with weight 3.0) in the range 0.32 <= <= , then the algorithm produces the following optimized seven sample filter:

The gradient can then be calculated as in eq. .

* Gaussian gradient filters - In modern digital image processing one of the most common techniques is to use a Gaussian filter (see Section 9.4.1) to accomplish the required smoothing and one of the derivatives listed in eq. . Thus, we might first apply the recursive Gaussian in eq. followed by eq. ii to achieve the desired, smoothed derivative filters hx and hy. Further, for computational efficiency, we can combine these two steps as:

where the various coefficients are defined in eq. . The first (forward) equation is applied from n = 0 up to n = N - 1 while the second (backward) equation is applied from n = N - 1 down to n = 0.

* Summary - Examples of the effect of various derivative algorithms on a noisy version of Figure 30a (SNR = 29 dB) are shown in Figure 31a-c. The effect of various magnitude gradient algorithms on Figure 30a are shown in Figure 32a-c. After processing, all images are contrast stretched as in eq. for display purposes.

(a) (b) (c) Simple Derivative - eq. ii Sobel - eq. Gaussian (=1.5) & eq. ii

Figure 31: Application of various algorithms for hx - the horizontal derivative.

(a) (b) (c) Simple Derivative - eq. ii Sobel - eq. Gaussian (=1.5) & eq. ii

Figure 32: Various algorithms for the magnitude gradient, |a|.

The magnitude gradient takes on large values where there are strong edges in the image. Appropriate choice of in the Gaussian-based derivative (Figure 31c) or gradient (Figure 32c) permits computation of virtually any of the other forms - simple, Prewitt, Sobel, etc. In that sense, the Gaussian derivative represents a superset of derivative filters.

Second Derivatives

It is, of course, possible to compute higher-order derivatives of functions of two variables. In image processing, as we shall see in Sections 10.2.1 and 10.3.2, the second derivatives or Laplacian play an important role. The Laplacian is defined as:

where h2x and h2y are second derivative filters. In the frequency domain we have for the Laplacian filter (from eq. ):

The transfer function of a Laplacian corresponds to a parabola (u,v) = -(u2 + v2).

* Basic second derivative filter - This filter is specified by:

and the frequency spectrum of this filter, in each direction, is given by:

over the frequency range - <= <= . The two, one-dimensional filters can be used in the manner suggested by eq. or combined into one, two-dimensional filter as:

and used as in eq. .

* Frequency domain Laplacian - This filter is the implementation of the general recipe given in eq. and for the Laplacian filter takes the form:

* Gaussian second derivative filter - This is the straightforward extension of the Gaussian first derivative filter described above and can be applied independently in each dimension. We first apply Gaussian smoothing with a chosen on the basis of the problem specification. We then apply the desired second derivative filter eq. or eq. . Again there is the choice among the various Gaussian smoothing algorithms.

For efficiency, we can use the recursive implementation and combine the two steps--smoothing and derivative operation--as follows:

where the various coefficients are defined in eq. . Again, the first (forward) equation is applied from n = 0 up to n = N - 1 while the second (backward) equation is applied from n = N - 1 down to n = 0.

* Alternative Laplacian filters - Again one-dimensional digital filter design techniques offer us powerful methods to create filters that are optimized for a specific problem. Using the Parks-McClellan design algorithm, we can choose the frequency bands where we want the second derivative to be taken and the frequency bands where we want the noise to be suppressed. The algorithm will then produce a real, even filter with a minimum length that meets the specifications.

As an example, if we want a filter that has second derivative characteristics in a passband (with weight 1.0) in the frequency range 0.0 <= <= 0.3 and a stopband (with weight 3.0) in the range 0.32 <= <= , then the algorithm produces the following optimized seven sample filter:

The Laplacian can then be calculated as in eq. .

* SDGD filter - A filter that is especially useful in edge finding and object measurement is the Second-Derivative-in-the-Gradient-Direction (SDGD) filter. This filter uses five partial derivatives:

Note that Axy = Ayx which accounts for the five derivatives.

This SDGD combines the different partial derivatives as follows:

As one might expect, the large number of derivatives involved in this filter implies that noise suppression is important and that Gaussian derivative filters--both first and second order--are highly recommended if not required . It is also necessary that the first and second derivative filters have essentially the same passbands and stopbands. This means that if the first derivative filter h1x is given by [1 0 -1] (eq. ii) then the second derivative filter should be given by h1x h1x = h2x = [1 0 -2 0 1].

* Summary - The effects of the various second derivative filters are illustrated in Figure 33a-e. All images were contrast stretched for display purposes using eq. and the parameters 1% and 99%.

(a) (b) (c) Laplacian - eq. Fourier parabola - eq. Gaussian (=1.0) & eq.

(d) (e) "Designer" - eq. SDGD (=1.0) - eq.

Figure 33: Various algorithms for the Laplacian and Laplacian-related filters.

Other Filters

An infinite number of filters, both linear and non-linear, are possible for image processing. It is therefore impossible to describe more than the basic types in this section. The description of others can be found be in the reference literature (see Section 11) as well as in the applications literature. It is important to use a small consistent set of test images that are relevant to the application area to understand the effect of a given filter or class of filters. The effect of filters on images can be frequently understood by the use of images that have pronounced regions of varying sizes to visualize the effect on edges or by the use of test patterns such as sinusoidal sweeps to visualize the effects in the frequency domain. The former have been used above (Figures 21, 23, and 30-33) and the latter are demonstrated below in Figure 34.

(a) Lowpass filter (b) Bandpass filter (c) ighpass filter

Figure 34: Various convolution algorithms applied to sinusoidal test image.

<< >> Up Title Contents Index