3. Removing Noise from an Image

Much of the image processing done for the applications described here involves classifying digitized photographs into binary images (i.e. black, DN=0, and white, DN=255). Most commonly the color edit feature of xv is used to generate the black and white images, but because of irregularities in the illumination patterns of the original photographs, there are usually areas of noise, or misclassified pixels.

When this manual was originally written, in 1993, IPW supported two methods of removing noise from images in the form of image editing procedures. Each method is suitable for different types of noise. Now, software is available to remove noise interactively. xv version 3.10 can be used to remove rectangular areas of noise, and xpaint can be used to remove polygonal areas of noise.

However, I am leaving this section in this manual because it demonstrates important techniques used in the remainder of this manual, using a very simple application. Therefore I suggest that you continue through the examples shown in this section, as well as experiment with using xv and xpaint

The program fill uses a region growing technique to change the value of pixels within an area. This is useful for removing the noise from images with a few large isolated patches of misclassified pixels. For example, bright reflections are unfortunately common on photomicrographs of snow section cuts because the contrast enhancing treatments are inhomogeneous. The bright speckles appear in the profiles of snow grains cut by the section, but classify as pore space because the pore filler is lighter than the treated profiles. Figure 3.1 shows a digitized photomicrograph of a snow section, and figure 3.2 shows the same image classified.

The program scribe is used to change the values of all pixels within an outlined area. This technique is useful for removing the noise from images where there are large areas of noise that can be conveniently outlined by retangles or polygons. For example, a common method to record the roughness of a snow surface in the field, is by photographing a linear profile created by inserting a dark background, such as a dark metal plate or piece of wood into the snow. These photographs may be digitized and classified as shown in figure 3.3 and figure 3.4. The noise in these images tends to be more speckled than the isolated areas in the snow section images. Therefore it becomes more efficient to create outlines, retangles or polygons, around the noisy areas and change their value all at once. This program is also used to create masks for images, discused later. Some images require a combination of area filling and outline filling to remove unwanted noise

3.1 Fill

The image in this demonstration shows a much-magnified area on a section cut through a snow specimen. This particular section cut was prepared from old snow whose grains had formed grain clusters. The images for this demonstration are located in the directory ipwdemo/noise. Use cd to change directories. (The exact command is not given since it depends on which directory you are currently working in). Display the raw and classified images with xv

% xv section.raw.ipw &

% xv section.noise.ipw &

The `&' at the end of the xv command runs the command in the background, thus allowing two xv's to be run at once.

You will see the general outline of the grain cluster profile, but with `islands' just inside the perimeter. These are the areas that are misclassified. The desired result is a large area of continuous white (ice), with one small white island in the lower right of the pore area (black).

Open the xv coords window and enter a coords file name. Be sure to press enter, or click the OK button to open the coords file.

Select areas to be filled by moving the mouse to a pixel within each area you wish to eliminate, and selecting the point (using the f key with xv2.21, or the ' key with xv3.10).

Fill the areas by running fill to eliminate the noise

% fill -c coords -i section.noise.ipw -k 255 > section.clean.ipw

By default, fill changes the values to black. To set the pixels to a different value, use the the -k option to specify the new value. In this case the desried fill value is white (-k 255).

When the image is displayed at a large magnification, you'll noitce that some of the noise is touching the ice. Since fill uses region growing, it cannot be used to remove this noise because it will remove the ice as well. Use the program scribe as described in the next section to remove this noise.

3.2 Scribe

You may continue to work with the snow section image, or you may use a classified photograph of a snow roughness profile selected for this demonstration. In the snow roughness image, the black area represents the background and the white represents the snow. Display the raw and classified image with xv

% xv rough.raw.ipw &

% xv rough.noise.ipw &

Two areas of misclassified pixels can be seen in this image. One, in the upper left corner, could probably be handed with the program fill, or by cropping the cleaner areas of the image from the the noisey areas. However, there is also noise classified as snow in areas of the background, which are too numerous to fix efficiently with fill, and which are below the trace of the snow surface so cropping would also be inefficient. Therefore, the strategy here involves outlining the noisy areas with both retangles (quick and easy to draw) and polygons (more time consuming).

Outline the noise with a rectangle or a polygon by moving the cursor around an area of white pixels above the snow surface. Position the cursor in the outline after drawing and press the f key to tell xv, to fill the area. Continue outlining and marking some more of the noisy areas on the image to practise this method.

To remove noise from the image

% scribe -i rough.noise.ipw -k 0 -f > rough.clean.ipw

By default, scribe sets areas set to 255 (white). In this case we need the pixels to be set to 0 (black), so the -k option is used. The -f is used to run scribe in fill mode.

Display the resultant image:

% xv rough.clean.ipw

The cleaned version of two images used in this section are shown in figure 3.5 and figure 3.6.

Flowchart 1 depicts the noise removal process schematically.