Back to Index 

Filter Menu


The Filter menu provides commands for filtering images in both the spatial and the frequency domain. Like contrast stretching, filtering is a pixel-by-pixel transformation of the image. Unlike contrast stretching, however, the transformation depends not only on the graylevel of the pixel being processed, but also on the graylevels of neighboring pixels. Consequently, filtering is also termed a neighborhood or context-dependent operation.

With the exception of the Convolution command, all items on the Filter menu are enabled for all types of images. The Convolution command operates only on single-band images, and is enabled only when the current image is a single-band image.


Power Spectrum

The Power Spectrum command computes the squared modulus of the Fourier transform of the input image. The power spectrum is typically calculated for the entire image (default). However, the power spectrum may also be calculated on a row or column basis and averaged across the image. When the Row or Column Average is selected, the power spectrum is calculated for each row (or column) independently and then averaged across the entire image to produce the output image. If the input image is a multi-band image, the power spectrum calculation is performed on each band separately.

The graylevel value of a pixel in the output image O is computed as

where I is the input image, FFT( ) is the discrete Fourier transform (see the description of the Filter > FFT command for details), and functions re( ) and im( ) deliver the real and imaginary parts of a complex number, respectively.

The power spectrum image typically has a very large dynamic range that can be visually improved using contrast stretches such as Contrast > Logarithmic Stretch, or Contrast > Square Root Stretch (sometimes repeating several times). The Power Spectrum command is useful for detecting periodic image or noise patterns.


FFT Convolution

The FFT Convolution command convolves an image with either:

This is done by computing the discrete Fourier transform of the image, multiplying it either by the Fourier-transformed spatial kernel, or by the frequency-domain filter, and computing the inverse Fourier transform of the result. Both the number of lines/band and the number of pixels/line of the input image must be powers of two. The filter image is chosen from a pop-up menu of all images currently on the desktop.

The graylevel of a pixel in the output image O is computed from the input image I and the filter image F as

where FFT( ) denotes the discrete Fourier transform, and ( ) the inverse Fourier transform (see the description of the Filter > FFT command below for details). The FFT Convolution command uses cyclic, wrap-around convolution to determine the pixel values at the image borders.

A spatial kernel image is easily created with the File > New > Function command.


FFT Filter

The FFT Filter command spatially convolves an image by computing the discrete Fourier transform of the image, multiplying it by a specified frequency domain filter function, and computing the inverse Fourier transform of the result. Both the number of lines/band and the number of pixels/line of the input image must be powers of two.

The filter function is chosen from a pop-up menu containing a variety of functions. Other parameters are the radii of the filter function, the filter type, and, in the case of a high-pass filter, a filter parameter. A filter parameter value of one (the default) creates a high-pass filter, and values greater than one result in a parametric high-boost filter.

The graylevel of a pixel in the output image O is computed from the input image I and the frequency-domain filter F as

where c is the filter parameter, as specified in the dialog. The FFT Filter command uses cyclic, wrap-around convolution to determine the pixel values at the image borders.

The various filter functions F are defined as follows:

where

, and are normalized spatial frequencies, and are the radii of the filter function, as specified in the dialog, and e is the base of the natural logarithm (i.e., e = ln(1) = 2.718282…).

The FFT Filter command is faster than the FFT Convolution command, because only two FFTs are required, compared to three for the FFT Convolution command. All filters available through the FFT Filter command are amplitude-only, and do not modify the phase term.

The parametric high-boost filter is discussed in R.A. Schowengerdt, Remote Sensing: Models and Methods for Image Processing, Academic Press, San Diego, CA, 1997. Generally, the larger the value of the filter parameter, the less the degree of edge enhancement. ,


FFT (Fast Fourier Transform)

The FFT (Fast Fourier Transform) command performs an image transformation. The forward transform converts the image from the spatial to the frequency domain; the inverse transform converts the image from the frequency to the spatial domain. For the FFT command, both the number of lines/band and the number of pixels/line must be powers of two.

The inverse FFT transform destroys its input image!

The graylevel of a pixel in the output image O is computed from the input image I as

where x and z are frequency domain coordinates, e is the base of the natural logarithm (i.e., e = ln(1) = 2.718282…), and i is the complex number . The spatial domain image (I in the case of the forward transform, O in the case of the inverse transform) is assumed to be of size m-by-n-by-o. For more information on the fast Fourier transform, see G. D. Bergland, "A guided tour of the fast Fourier transform," IEEE Spectrum, Vol. 6, No. 7 (July 1969), pp. 41—52.

Pixel values in the frequency domain are complex numbers (versus real numbers in the spatial domain). tclSADIE represents complex numbers with two graylevels – one graylevel for the real part, and one for the imaginary part. Consequently, a frequency domain image has twice as many pixels/line as the corresponding spatial domain image, with columns alternating between real and imaginary values. A complex image may be separated into its real and imaginary or magnitude and phase parts with the Multi > Complex > Real command. The FFT command is useful for analyzing the frequency characteristics of an image.


FHT (Fast Hartley Transform)

The FHT (Fast Hartley Transform) command uses a different and more efficient algorithm to perform forward and inverse Fourier transforms on an input image.

The FHT requires the number of lines and number of pixels/line to be equal and also a power of 2.

The inverse FHT transform does not destroy its input image.

The graylevel of a pixel in the output image O is computed from the input image I as

where x and z are frequency domain coordinates, e is the base of the natural logarithm (i.e., e = ln(1) = 2.718282…), and i is the complex number . The spatial domain image (I in the case of the forward transform, O in the case of the inverse transform) is assumed to be of size m-by-n-by-o. For more information on the fast Hartley transform, see R. N. Bracewell, The Hartley Transform, Oxford University Press, New York, NY, 1986.

The format of frequency domain (complex) images is described under the FFT command (see above). The FHT command is useful for analyzing the frequency characteristics of an image, and for efficiently performing convolution and filtering operations on large images.


Convolution

The Convolution command convolves an image with a kernel in the spatial domain. The kernel may be given either as an image, or it may be numerically specified as a mask (the default), up to a maximum size of 7-by-7. If the kernel is specified as a mask (matrix), the horizontal and vertical size of the matrix, and the individual matrix values must be specified. Each mask value is multiplied by a factor, which, for a mask of size m-by-n, defaults to . The factor is adjusted automatically whenever the size of the mask is changed. If the spatial kernel is to be given as an image, it may be chosen from a pop-up menu of all images currently on the desktop. The size of the spatial kernel image must be odd in both the vertical and the horizontal direction, and the spatial kernel image must be single-band. If the spatial kernel is an image, no normalization is performed.

The graylevel of a pixel in the output image O is computed from the input image I and a spatial kernel K of size m-by-n as

Rows and columns within m/2 lines or n/2 pixels of the borders of the convolved image are filled with graylevel values copied from the nearest valid row or column.

A spatial kernel image is easily created with the File > New > Function command. It may be saved as an image for later use with other images.

While producing essentially the same output image as the FFT Convolution command , the Convolution command may be more efficient when the kernel is small.


Gradient (Library Mask)

The Gradient (Library Mask) command convolves an image with two spatial kernels – a horizontal and a vertical mask. It then combines the results in a vector calculation to produce two output images, one representing the magnitude and the other representing the direction of the gradient at each point of the input image. The masks (gradient operators) are chosen from a pop-up menu of common gradient operators.

The graylevel of pixels in the magnitude image M and the direction image D are computed from the input image I and two m-by-n kernels and as

where

,

,

v and h denote vertical and horizontal components, respectively, and ( ) represents the trigonometric inverse tangent function. Rows and columns within m/2 lines or n/2 pixels of the borders of the convolved image are filled with graylevel values copied from the nearest valid row or column.

The following choices are available for the horizontal and vertical kernels, and :

Gradient operators are useful for detecting edges (i.e., sudden changes in graylevel) in an image. They are discussed in detail in G. S. Robinson, "Detection and Coding of Edges Using Directional Masks," Optical Engineering, Vol. 16, No. 6 (November/December 1977), pp. 580—585. Note that the direction map for the Roberts filter is p/4 radians out of phase with those for the other filters.


Gradient (User Mask)

The Gradient (User Mask) command convolves an image with two spatial kernels – a horizontal and a vertical mask. It then combines the results in a vector calculation to produce two output images, one representing the magnitude, the other representing the direction of the gradient at each point of the input image. The kernels (gradient operators) may be given either as images, or numerically specified as masks (the default). If the kernels are specified as masks (matrices), the horizontal and vertical size of the matrices, and the individual matrix values must be specified. If the kernels are to be given as images, they may be chosen from a pop-up menu of all images currently on the desktop. The size of the kernel images must be odd in both the vertical and the horizontal direction, and the kernel images must be single-band.

The graylevel of pixels in the magnitude image M and the direction image D are computed from the input image I and two m-by-n kernels and as

where

,

,

v and h denote vertical and horizontal components, respectively, and () represents the trigonometric arc tangent function. Rows and columns within m/2 lines or n/2 pixels of the borders of the convolved image are filled with graylevel values copied from the nearest valid row or column.

Gradient operators are particularly useful for detecting edges (i.e., sudden changes in graylevel) in an image. They are discussed in detail in G. S. Robinson, "Detection and Coding of Edges Using Directional Masks," Optical Engineering, Vol. 16, No. 6 (November/December 1977), pp. 580—585. Note that you can use kernels of size 2-by-2 by simply padding a 3-by-3 kernel with zeros.


Variance Map

The Variance Map command computes a map of the input image, where the graylevel of a pixel in the output map represents the graylevel variance within a window centered at the corresponding pixel of the input image. Parameters are the vertical and horizontal window size, which must both be odd.

The graylevel of a pixel in the output image O is computed from the input image I and a window of size m-by-n as

Rows and columns within m/2 lines or n/2 pixels of the borders of the convolved image are filled with graylevel values copied from the nearest valid row or column.

Like the Diversity Map command (see below), the Variance Map command generates an image representing the local contrast (graylevel variation) in the input image. It is useful for creating a spatial texture or edge activity feature map from an image. With a suitable graylevel threshold applied afterwards (see the Contrast > Threshold Graylevels command), the variance operation can be a useful edge detector for some images.


Diversity Map

The Diversity Map command computes a map of the input image, where the graylevel of a pixel in the output map represents the number of different graylevels within a window centered at the corresponding pixel of the input image. Parameters are the vertical and horizontal window size, which must both be odd.

The graylevel of a pixel in the output image O is computed from the input image I and a window of size m-by-n as

Rows and columns within m/2 lines or n/2 pixels of the borders of the convolved image are filled with graylevel values copied from the nearest valid row or column.

The Diversity Map command generates an image representing the local contrast (graylevel variation) in the input image. It is particularly useful for creating a map of local class heterogeneity from a classification map.


Majority Filter

The Majority Filter command filters the input image by creating an output image in which the graylevel of a pixel represents the majority graylevel within a window centered at the corresponding pixel of the input image. Parameters are the vertical and horizontal window size, which must both be odd, and a weight for the influence of the class of the pixel in the center of the window.

The graylevel of a pixel in the output image O is computed from the input image I and a window of size m-by-n as

where

,

and w is the center pixel weight specified in the dialog.

Rows and columns within m/2 lines or n/2 pixels of the borders of the convolved image are filled with graylevel values copied from the nearest valid row or column. Pixels within the window are separated into classes according to graylevel values; an input image with integer-valued graylevels is therefore desirable but not required. The majority filter is described in R. A. Schowengerdt, Techniques for Image Processing and Classification in Remote Sensing, Academic Press, New York, NY, 1983, pp. 188—190.

Like the Median Filter command (see below) and the Conditional Average command (see below), the Majority Filter command is useful for smoothing a n image. The amount of smoothing can be controlled to some extent by the center pixel weight parameter. A value of one results in unbiased smoothing, a value less than one biases the smoothing in favor of neighboring pixels, and a value greater than one biases the smoothing in favor of the center pixel. The Majority Filter command is especially useful for classification map smoothing.


Median Filter

The Median Filter command filters an input image by creating an output image where the graylevel of a pixel represents the median graylevel within a window centered at the corresponding pixel of the input image. Parameters are the vertical and horizontal window size, which must both be odd.

The graylevel of a pixel in the output image O is computed from the input image I and a window of size m-by-n as

where , 1 <= l <= m*n , is a list of the graylevel values of all pixels within the window, in ascending order. Rows and columns within m/2 lines or n/2 pixels of the borders of the convolved image are filled with graylevel values copied from the nearest valid row or column.

The Median Filter command is useful for removing isolated pixel or line noise in an image. For line (or column) noise removal, the window should be rectangular and oriented perpendicular to the noise.


Minimum Filter

The Minimum Filter command filters an input image by creating an output image where the graylevel of a pixel represents the minimum graylevel within a window centered at the corresponding pixel of the input image. Parameters are the vertical and horizontal window size, which must both be odd.

The graylevel of a pixel in the output image O is computed from the input image I and a window of size m-by-n as

Rows and columns within m/2 lines or n/2 pixels of the borders of the convolved image are filled with graylevel values copied from the nearest valid row or column.

The Minimum Filter command is useful for dilating (expanding) dark objects against a lighter background, or eroding (thinning) light objects against a darker background. In general, the results can not be exactly reversed by using the Maximum Filter command.


Maximum Filter

The Maximum Filter command filters an input image by creating an output image where the graylevel of a pixel represents the maximum graylevel within a window centered at the corresponding pixel of the input image. Parameters are the vertical and horizontal window size, which must both be odd.

The graylevel of a pixel in the output image O is computed from the input image I and a window of size m-by-n as

Rows and columns within m/2 lines or n/2 pixels of the borders of the convolved image are filled with graylevel values copied from the nearest valid row or column.

The Maximum Filter command is useful for dilating (expanding) light objects against a darker background, or eroding (thinning) dark objects against a lighter background. In general, the results can not be exactly reversed by using the Minimum Filter command.


Conditional Average Filter

The Conditional Average Filter command filters an input image by creating an output image where the graylevel of a pixel represents a conditional average of the graylevels within a window centered at the corresponding pixel of the input image. Parameters are the vertical and horizontal window size, which must both be odd, a set size threshold, and a graylevel difference threshold.

The graylevel of a pixel in the output image O is computed from the input image I and a window of size m-by-n as

where

,

c is the set size (cardinality) threshold, and t is the graylevel difference threshold, as specified in the dialog.

Rows and columns within m/2 lines or n/2 pixels of the borders of the convolved image are filled with graylevel values copied from the nearest valid row or column.

This filter is a generalization of the conditional average filter described in T. Ryan, "Image Segmentation Algorithms," SPIE, Vol. 534 (1985), pp. 172—178. All pixels within the window whose graylevels differ from that of the center pixel by less than the graylevel threshold t are collected into set S. If the size of S is greater than the cardinality threshold c, the average of the graylevel values in S is assigned as the new graylevel value of the center pixel. If S has cardinality less than or equal to c, and the maximum difference between any two pixels not in the set is less than t, the center pixel is assigned the average graylevel of all pixels not in S. If neither case is true, the center pixel’s graylevel value remains unchanged.

Like the Majority Filter command and the Median Filter command (see above), the Conditional Average Filter command is useful for smoothing an image. The first case in the computation above represents the smoothing component of the filter, where the amount of smoothing depends on both the set size threshold and the graylevel difference threshold. The amount of smoothing decreases as the set size threshold increases from 0 to m*n, and it increases with an increasing graylevel difference threshold. The second case is useful for eliminating isolated noise in the image, but this aspect of the filter can be suppressed by setting the set size threshold to zero.


Last Updated: August 2000
University of Arizona
Electrical and Computer Engineering Department
Digital Image Analysis Laboratory © 1999,2000