# DPlngScan

### The Filter Menu

Filters allow you to modify an image depending on it's contents. For example using filters you can blur images or sharpen them. There are two main types of filters 'User filters' which can be set up and modified at will, and the filters which are built into the program. The filter menu is shown to the right. If there is a selected area, the filter will apply just to that, otherwise it will apply to the entire image.

### Built in filters

#### Invert

This replaces pixels in the image by their inverse. Black becomes white, colours are replaced by their complements.

#### Histogram

This is slightly more than just a filter. When you select it, a histogram of the image will be calculated. This shows the number of pixels in each of a number of intensity levels or bands (16 by default). If the image is a 24 or 32 bit image then a much larger value may be used, e.g. 64 or 128 levels.

The Red, Green and Blue buttons can be used to choose which components are displayed. These buttons operate in a slightly different way to usual. Clicking with Select will select just one of them, more than one can be selected by clicking with Adjust. The same principle usually applies to multiple selections e.g. files.

The 'Equalise' button will attempt to spread out the pixels in the image so that there are equal intensities in each band.

Under the histogram, are two arrows which can be dragged from side to side. When Expand is clicked on, the range of intensities between the arrows will be expanded to fill the full range.

Expand and Equalise are crude tools. They may be of use with images where all the pixel intensities have been squashed into a narrow band. Finally the 'Recalc' button can be used to recalculate the histogram if the image is changed, or to use a different number of levels.

#### Max

This filter replaces each pixel by the maximum of itself and the surrounding 8 pixels. The maximum of 1,2,3,4,5 is 5.

#### Min

This filter replaces each pixel by the minimum of itself and the surrounding 8 pixels. The minimum of 1,2,3,4,5 is 1.

#### Median

This filter replaces each pixel by the median of itself and the surrounding 8 pixels. The median of a set of values is the value which splits the set into two equal parts. For example the median of 1,2,3,4,5 is 3. This filter is useful for removing noise from an image.

#### Average

This filter replaces each pixel by the average of itself and the surrounding 8 pixels. For example the average of 1,2,3,4,5 is (1+2+3+4+5)/5=3.

#### Add Noise

This adds random noise to the image. The amount of noise is controlled by the slider and writable icon at the top of the dialogue box. The button 'White noise' controls if equal amounts of noise will be added to the colour components of the image. If 'White noise' is selected, the image will retain its colour. If it is not selected the image will tend to develop coloured dots. Noise may be useful in making images look more life like. For example images which have been processed into a small number of brightness levels. By adding noise the obvious levels can be smoothed out slightly.

### User Filters

Technically speaking all the user filters are 'convolution filters' - each pixel is replaced by a combination of the values of its neighbours and itself. The combination is a fixed set of numbers - unlike for the Maximum and other filters above. The coefficient of each pixel can be specified, along with a global scale factor and a shift.

The user filter menu will always have as it first entry 'Edit...' Selecting this will open the Edit user filter window. Underneath this the names of all the filters that have been defined will appear. These filters work like the built in ones, clicking on the name applies the filter. User filters will apply to just the selected area of the image, or to all of it.

Some of the user filters supplied are 'Sharpen' to make images look sharper, and 'Blur' (the opposite of sharpen) to make images more fuzzy. It can be useful to sharpen images before applying some of the colour dithering techniques described in the Colour menu.

#### Edit user filter

The centre position in the matrix of writable icons represents the current pixel, the other icons then represent its neighbours. Often only the central 3x3 area will be used. The bottom two icons show the overall scale and shift factors. Pixel intensities are always between 0 and 255. Clicking on the right pointing arrow at the top of the window will open a menu showing all the filters that are defined and by selecting one, you can change the filter displayed.

The row of buttons along the bottom of the window allow you to carry out various operations on user filters.

#### New

This opens a window allowing you to enter the name of a new filter and the name of the filter to base it on.

#### Rename

This opens a window similar to New, but allowing you to change the name of the filter.

#### Delete

This deletes the current filter.

#### Cancel

Closes the Edit filter window, and leaves the current filter unchanged.

#### OK

Close the Edit filter window and saves the new filter definitions to disc. More technical users may wish to know that the filter definitions are kept in a text file called Resources.Filters.

### Some filter examples

Some examples may make how to use these filters more clear. The first example is a filter that does nothing, it just leaves the image unaltered.

0,0,0 0,1,0 0,0,0 |  | Shift=0 Scale=1

Only the central 9 entries are shown, the rest should be 0. So for each pixel there will be one contribution from the current pixel and none from its neighbours. The output intensity will be the same as the input.

Next a filter that inverts the image.

0,0,0 0,1,0 0,0,0 |  | Shift=255 Scale=-1

A filter that sharpens an image (Sharpen).

-1,-1,-1 -1,10,-1 -1,-1,-1 |  | Shift=0 Scale=2

Note that the sum of the central pixels and its neighbours is (-8+10)/2=1.

By changing the filter weights we can construct a filter that has the same effect but is not as strong (SlightSharpen).

-1,-1,-1 -1,20,-1 -1,-1,-1 |  | Shift=0 Scale=12

Again note that (-8+20)/12 equals 1.

The Edit menu | Index | The Colour menu

DPlngScan is © David Pilling, 1993
Email:chris@chris-johnson.org.uk