## Noise Filters

In amateur CCD images, there are two kinds of noise: the random noise of photon and electron statistics, and the impulse noise of cosmic rays and hot pixels. Pixel values in random noise cling to some central value, whereas pixel values afflicted

Figure 15.8 For whatever reason, you are sometimes stuck with a very noisy image. On the left is a highly enlarged image with hot pixels, on the right the same image after the application of a noise filter. The highly deviant hot pixels have been replaced with pixels that "belong" in the local neighborhood.

Figure 15.8 For whatever reason, you are sometimes stuck with a very noisy image. On the left is a highly enlarged image with hot pixels, on the right the same image after the application of a noise filter. The highly deviant hot pixels have been replaced with pixels that "belong" in the local neighborhood.

by impulse noise appear as large departures from a central value. The purpose of a noise filter is to analyze the statistical properties of the neighborhood around each pixel, determine whether the pixel is impulse noise, and if it is, replace it.

All noise filters that operate in the spatial realm rely on the fact that the numerical values of adjacent pixels in a properly sampled image are strongly correlated. However, if an image is severely undersampled, stars in it will appear as one pixel that deviates strongly from the sky background; and the noise filter will replace those pixels because, statistically, such stars are noise.

The rank median operator is sometimes used to remove noise, especially impulse noise, from faulty digital transmissions. Unfortunately, the median filter operates the same for all pixels, so that it often removes detail as well as noise. The standard noise filter described here is a median filter that activates only when a pixel exceeds the range of values characteristic of the image.

The following procedure replaces any pixel that deviates by a specified amount that is greater than the next-most-deviant pixel in the neighborhood. The procedure that follows removes noise from 3x3 neighborhoods:

NEXT i

sigma = (neighbor(8) - neighbor(2)) / 2 IF old(x,y) > neighbor(5) + sigs * sigma THEN

NEXT y where SORT is a function that sorts the array neighbor () into ascending order, sigma is the standard deviation, and sigs is a user-set parameter specifying the number of standard deviations allowed.

The loops in i and j load neighborhood pixels into the array neighbor starting with neighbor (1) and ending with neighbor (9). After sorting, neighbor (9) contains the pixel with the highest value in the neighborhood.

Rather than simply replacing the original pixel if it is an extreme, we want its statistical "fit" to determine whether we should keep it or replace it. In a normal distribution, 68% of the values lie within one standard deviation of the mean; in a sample of nine pixels, the closest we can come to this is to treat the inner seven pixels as falling within one standard deviation of the mean. This means that half the difference between neighbor (8) and neighbor (2 ) is roughly one standard deviation.

The parameter sigs is defined by the user as the allowable deviation from the median in units of sigma; typically it is given a value from 1.5 to 2. If the current pixel exceeds the allowable limits, the routine replaces the current pixel with the median of the neighborhood, neighbor (5). The routine replaces the original pixel, if and only if, the original pixel has an extreme value relative to the neighborhoodâ€”otherwise it does nothing.

â€˘ Tip: The noise filter in AIP4Win allows you to specify the trigger level in the noise filter, specifying that the deviant pixel must exceed the second-most-extreme by a factor that you have set. This gives better control over the strength of the filtering.

In Chapter 18, we describe a more sophisticated class of noise filters that use wavelet technology to identify and filter out noise. Wavelet filters employ a hybrid approach that combines frequency analysis with spatial filtering.