STScI Logo

median images.imfilter


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

NAME

median -- median filter a list of images

USAGE

median 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 median filter. Xwindow and ywindow are assumed to be odd integers. If either xwindow or ywindow are even they will be rounded up to the nearest odd integer.
zloreject = INDEF, zhireject = INDEF
The minimum and maximum good pixel 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

MEDIAN takes a list of input images input and produces a set of filtered output images output . The median filter consists of a sliding rectangular window of dimensions xwindow by ywindow . The center pixel in the window is replaced by the median of all the pixels in the window, where the median of a sequence of numbers is defined to be the value of the (n + 1) /2 pixel. If even the window dimensions are rounded up to odd integers. 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 median filtering box. If no good data is left in the filtering box, the median 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.

EXAMPLES

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

   im> median m74 m74.5by5 5 5

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

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

3. Median filter the test image dev$pix, removing all pixels less than 5 or greater than 19935 from the filtering box.

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

TIME REQUIREMENTS

Median 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 FMEDIAN is significantly more efficient than MEDIAN and should be used if the image is integer or can be quantized without significant loss of precision.

SEE ALSO

fmedian, rmedian, frmedian


Source Code · Search Form · STSDAS