Generic Image Processing Operations

Image processing operations are algorithms that map input images into output images. A digital image is defined as "a 2-dimensional rectangular array (lines, samples) of quantized brightness levels (pixels)." The term generic image processing operation denotes a fundamental image processing operation that may be used as a `building block' to construct more complicated processing operations (Frew and Dozier, 1986).

IPW programs are available for the following generic image processing operations: histogram computation (hist), look-up table driven intensity transformation (lutx), subimage extraction (window), multiplexing or interleaving (mux), binary operations (bitcom), linear arithmetic operations (lincom), image multiplication (mult), multivariate statistics computation (mstats), and convolution (convolve).

The following sections describe several image processing applications which can be performed using a combination of generic image processing operations.

Look-up Table Transformations

The use of look-up tables is a versatile technique in image processing. In cases where the spatial location of the pixel in the image is not considered, a look-up table, a mapping of input value to output value, can be used. Look-up tables are stored as IPW images, having one line and 2 ^ nbits samples. The sample coordinate in the look-up table equals the input value, and the value of each pixel in the look-up table represents the new contrast-stretched output value of the pixel in the image associated with the look-up table.

Look-up tables can be manually created with the program mklut, or command sequence interp | mklut. In addition, several IPW shell scripts create look-up tables for specific applications. lutx is used to apply the look-up table to the image. The operation of a look-up table is shown in Figure 2.

Three specific applications using look-up tables are described below. Additionally, look-up table operations are used in image processing applications described later.

Renumbering

There are applications where it is desirable to change the DN value of a particular value in an image. This can be achieved creating a look-up table with the desired input and output values.

Two-byte to one-byte remapping

Many images are stored in two bytes. In order to display these images on an 8-bit display, (i.e. most color displays including the Sun Workstation) it is necessary to compress them to 8 bits. This can be achieved creating a look-up table which linearly maps the significant input bits to 8 bits of output. For example a look-up table which linearly maps 0 - 4095 to 0 - 255 can be used to convert a 2-byte image with 12 significant bits to a 1 byte image. (the file $crrel/lib/lut/12-8.lut contains this look-up table.) A non-linear mapping can be used for cases in which the image is not evenly distributed throughout the 2 bytes of input. This could decrease the loss of precision in the conversion. [Note: it would not be practical to use a look-up table for images which use all 16 bits, since the look-up table would contain 65536 entries.]

Contrast Stretching

Many images have relatively poor contrast and use only a small part of the possible range of brightness values. This situation can be improved by contrast stretching the image. A contrast stretch is a `point operation': each pixel value in the input image maps directly to a pixel value in the output image.

Contrast stretching is implemented in xv. However, there are occasions when it is preferable to use an IPW program to perform a contrast stretch. For example, when working with a large number of images for which an automatic method of contrast stretching is appropriate, it is easier to write a shell script to use an IPW program to apply the stretch to all the images rather than to use xv and stretch and save each image individually.

There are currently two IPW contrast stretch programs, alinear and histeq. These programs are written as shell scripts which create an IPW look-up table based on the image histogram. alinear is an automatic linear contrast stretch. It determines the minimum and maximum values in the image (from the image histogram) and stretches those values linearly from 0 to 255. histeq performs a histogram equalization (also known as an equal area stretch). This stretch attempts to create a `flat' histogram, that is, it tries to assign an equal number of pixels to each output brightness value. Both these programs have options to specify the range of the input and output DN values.

Image Filtering

Spatial filtering is used for image smoothing, edge detection and edge enhancement. In the spatial domain, image filtering is a convolution operation; i.e. a weighted sum of the neighboring pixels. The set of filter weights is the convolution kernel.

Image smoothing (a form of noise reduction) is performed using an averaging, or mean filter. This is accomplished by using weights that sum to 1. Typically, uniform weights are used, however, better smoothing results from a centrally weighted filter. For example, the following weights are used for a 3x3 kernel:

	1/9 1/9 1/9            1/16 1/8 1/16
	1/9 1/9 1/9            1/8  1/4 1/8
	1/9 1/9 1/9            1/16 1/8 1/16

The Laplacian filter is commonly used for edge detection. The following kernel is used for the Laplacian filter.

         0 -1  0               -1 -1 -1
        -1  4 -1               -1  8 -1
         0 -1  0               -1 -1 -1

Edge enhancement can be achieved by adding the original image to the Laplacian filtered image. The following kernel accomplishes this.

         0 -1  0               -1 -1 -1
        -1  5 -1               -1  9 -1
         0 -1  0               -1 -1 -1

Many other convolution kernels are used and are discussed in detail in most image processing texts (eg. Jensen, 1986).

The generic image processing function convolve) is used for image filtering. Kernels can be entered using mkkern) or with an editor, such as vi.

Image Masking

Image masking is a versatile technique in which certain areas of interest are highlighted. Masking is useful for training site selection in image classification as well as more general applications in which statistics are required for selected areas. A mask image is an image which contains the value 255 in the area of interest and zero elsewhere. The following steps are used to create a mask image.

1) A `blank' image (ie. an image that contains all zeros) of the same dimension as the original image is necessary in order to create the mask. This is most easily accomplished by applying a look-up table containing all zeros to the image. blank is a shell script which uses lutx to perform this operation.

2) The polygon drawing feature of xv can be used to outline areas of interest on the image.

3) poly determines the line and sample coordinates of all points within the polygon, based on the vertices of the selected polygon.

4) edimg is used with the `blank' image to set the values of the pixels deterimed by poly to 255.

The shell script scribe combines the function of both poly and edimg

The generic image processing function bitcom is used to compute a bitwise `and' between the original image and the mask resulting in an image with the original image values in the area of interest and zeros elsewhere. In addtion, the mask can be used as an input to mstats and hist to generate statistics and histograms for the area of interest.

Principal Components Analysis

Principal components analysis is a useful technique for image data reduction. The axes of the original data are rotated to incorporate the maximum data variance in the first component. Each additional component is set orthogonal to the previous ones and captures the maximum remaining variance. This produces a set of uncorrelated images. The number of output components is equal to the original number of image bands. The last components usually contain most of the noise in the data and are often discarded. The first few components typically contain most of the meaningful scene brightness variance. Consequently, principal components analysis is a method of data reduction and image enhancement. However, the new synthetic bands, which are a linear combination of the input bands, are often difficult to interpret.

In IPW, computing principal components images is performed using a combination of three generic image processing operations: mux, mstats and lincom and an algebraic operation, jacobi The following steps are used to compute principal component images:

1) Interleave the image using mux.

2) Compute the covariance matrix for the entire image using mstats.

3) Compute the eigenvalues and eigenvectors for the covariance matrix using jacobi (Press et al., 1986).

4) Sort the eigenvectors in descending eigenvalue order (most variance goes to the first component).

5) Use lincom to multiply the image matrix by the transformation matrix of eigenvectors.

Image Ratioing

Image ratioing is commonly used as a vegetation index, to remove the variable effects of topography, (i.e. illumination) or to emphasize certain surface chemicals evident for vegetation free rocks and soils. It is important to atmospherically correct the images before ratioing. A common approximate correction for the path radiance component of the atmospheric effect on the image is to determine the DN value of a dark, clear lake, and subtract that value from the image.

A combination of three generic image processing operations is used to perform image ratioing:

1) To perform atmospheric correction, the image is modified by a constant value. A look-up table transformation is a fast and efficient way to change an image by a constant value. This is implemented by the shell script addc. which creates a look-up table and applys it using lutx.

2) The shell script ratio uses mux to interleave the images and mult to compute the image ratio by multiplying the first band of the input image by the reciprocal of the second band.