ZAP: Non-Interactive Image Median Filter

ZAP will edit and/or mask high or low pixels in an image, or perform whole-image median filtering.

For each pixel, ZAP computes the mean, median, and standard deviation of all of the pixels within a 5x5 box centered on that pixel. The SIZE keyword can be used to change the size and aspect ratio of this box. Any pixels within this box deviate by more than 5-sigma (or f-sigma, using the SIG=f keyword) from the median are replaced by the median. If the MASK keyword is given, the pixels are masked rather than replaced. The 'BOX=n' keywords will limit ZAP's attention to that portion of the image within box 'n'.

ZAP will replace all pixels within the current box that exceed the rejection threshold for the region centered on a particular pixel. To only ZAP the pixel at the center of the current filtering window, use the SURGICAL keyword.

If the SIG=0 keyword is given, zap will in effect median smooth the image within the window given by the size command, replacing all pixels by the median of them and their surroundings.

ZAP is a rather drastic command that should be used with great care. In general, ZAP is not a good way to clean an image of cosmic ray events, especially if the images of your objects have sharp cores (e.g., under- or critically-sample stellar images or emission lines). In these cases, it is best to use the interactive TVZAP to edit the bad pixels in an image if there is a small number of these that may be handled interactively. If cosmic rays are a big problem (e.g., like in HST images) and you have multiple images (e.g., CRSPLIT observations), you should use the MEDIAN, BIGMEDIAN, or PICCRS routines, as appropriate. If your observing strategy (or the source of your images) did not allow use of multiple images for statistical cosmic-ray rejection, careful and judicious interactive cleaning using TVZAP is suggested over blind zapping using ZAP.


A related command is TVZAP, which allows you to select which pixels are to be zapped interactively using the TV cursor. LZAP works with a list of known bad pixels.