### GLITCH

Replaces bad pixels in a two-dimensional NDF with the local median

#### Description:

This routine removes bad pixels from a two-dimensional NDF , replacing them with the median of the eight (or less at the edges) neighbouring pixels. At least three of these eight neighbouring pixels must have good values (that is, they must not set to the bad value) otherwise the resultant pixel becomes bad.

The positions of the pixels to be removed can be supplied in four ways (see Parameter MODE):

• In response to parameter prompts. A single bad pixel position is supplied at each prompt, and the user is re-prompted until a null value is supplied.

• Within a positions list such as produced by applications CURSOR, LISTMAKE.

• Within a simple text file. Each line contains the position of a pixel to be replaced.

• Alternatively, each bad pixel in the input NDF can be used (subject to the above requirement that at least three out of the eight neighbouring pixels are not bad).

#### Usage:

glitch in out [title] $\left\{\right\$
incat=? infile=? pixpos=?

mode

#### Parameters:

The input image.
A catalogue containing a positions list giving the pixels to be replaced, such as produced by applications CURSOR, LISTMAKE. Only accessed if Parameter MODE is given the value "Catalogue".
The name of a text file containing the positions of the pixels to be replaced. The positions should be given in the current co-ordinate Frame  of the input NDF, one per line. Spaces or commas can be used as delimiters between axis values. The file may contain comment lines with the first character # or !. This parameter is only used if Parameter MODE is set to "File".
The method used to obtain the positions of the pixels to be replaced. The supplied string can be one of the following options.
• "Bad" –- The bad pixels in the input NDF are used.

• "Catalogue" –- Positions are obtained from a positions list using Parameter INCAT.

• "File" –- The pixel positions are read from a text file specified by Parameter INFILE.

• "Interface" –- The position of each pixel is obtained using Parameter PIXPOS. The number of positions supplied must not exceed 200.

[current value]

##### OUT = NDF (Write)
The output image.
The position of a pixel to be replaced, in the current co-ordinate Frame of the input NDF. Axis values should be separated by spaces or commas. This parameter is only used if Parameter MODE is set to "Interface". If a value is supplied on the command line, then the application exits after processing the single specified pixel. Otherwise, the application loops to obtain multiple pixels to replace, until a null (!) value is supplied. Entering a colon (":") will result in a description of the required co-ordinate Frame being displayed, followed by a prompt for a new value.
Title for the output image. A null value (!) propagates the title from the input image to the output image. [!]

#### Examples:

Reads pixel positions from the positions list stored in the FITS file badpix.FIT, and replaces the corresponding pixels in the two-dimensional NDF m51 by the median of the surrounding neighbouring pixels. The cleaned image is written to cleaned.sdf.

#### Notes:

• If the current co-ordinate Frame of the input NDF is not PIXEL, then the supplied positions are first mapped into the PIXEL Frame before being used.

#### Implementation Status:

• This routine correctly processes the AXIS, DATA, QUALITY, VARIANCE, LABEL, TITLE, UNITS, WCS, and HISTORY  components of the input NDF and propagates all extensions.