STScI Logo

mode images.imfilter


NAME · USAGE · PARAMETERS · DESCRIPTION · REFERENCES · EXAMPLES
TIME_REQUIREMENTS · BUGS · SEE_ALSO

NAME

mode -- modal filter a list of images

USAGE

mode input output xwindow ywindow

PARAMETERS

input
List of input images.
output
List of filtered images. The number of input images must be the same as the number of output images. If the input image name is the same as the output image name the original image is replaced by the filtered image.
xwindow, ywindow
The size of the modal filter. Xwindow and ywindow are assumed to be odd integers. Even values will be rounded up to the nearest odd integer.
zloreject = INDEF, zhireject = INDEF
The minimum and maximum good data values. Zloreject and zhireject default to -MAX_REAL and MAX_REAL respectively.
boundary = "nearest"
The type of boundary extension. The options are:
nearest
Use the value of the nearest boundary pixel.
constant
Use a constant value.
reflect
Reflect pixel values around the boundary.
wrap
Wrap pixel values around the boundary.
constant = 0.
The value for constant value boundary extension.

DESCRIPTION

MODE takes a list of input images input and produces a set of filtered output images output . The modal filter consists of a sliding rectangular window of dimensions xwindow by ywindow . The center pixel of the window is replaced by the mode of all the pixels in the window where the mode of a sequence of numbers is defined below.

		mode = 3. * median - 2. * mean

The median of a sequence of pixels is defined as the value of the (n + 1) / 2 number in the ordered sequence. Out of bounds pixel references are handled by setting the parameter boundary .

The zloreject and zhireject parameters may be used to reject bad data from the modal filtering box. If no good data is left in the filtering box, then the mode is set to zloreject if the majority of the pixels are less than zloreject, or to zhireject if the majority of pixels are greater than zhireject.

REFERENCES

A derivation of the expression for the mode used here can be found in "Statistics in Theory and Practice", Robert Lupton, 1993, Princeton University Press, problem 2.

EXAMPLES

1. Modal filter an image using a 5 by 5 window and nearest pixel boundary extension.

   im> mode m74 m74.5by5 5 5

2. Modal filter an image using a 3 by 3 window and constant boundary extension.

   im> mode m74 m74.5by5 3 3 boun=const const=0.

3. Modal filter the test image, rejecting pixels < 5 and > 19935 from the modal filter.

    im> mode dev$pix pix77 7 7 zlo=5 zhi=19935

TIME REQUIREMENTS

Mode requires approximately 11 and 19 CPU seconds to filter a 512 by 512 integer image using a 5 by 5 and 7 by 7 filter window respectively (SPARCStation2).

BUGS

The sort routine for the smaller kernels has been optimized. It may be desirable to optimize higher order kernels in future.

The IRAF task FMODE is significantly more efficient than MODE and should be used if the data can be quantized.

SEE ALSO

fmode, rmode, frmode


Source Code · Search Form · STSDAS