Image - Filter

The Filter command works with RGB or RGBa images and exposes the internal functioning of many commands in the Transform toolbar and allows us to add new, custom commands using convolution filters. Most users will apply the commands in the Transform toolbar without ever examining their matrix values in the Filter command. However, for those users who are so inclined, the Filter command provides an "open door" to altering existing filters and creating new ones. If a selection is present, Filter will ignore any unselected pixels. Filter will also ignore invisible pixels.


Many image effects are created through a mathematical process called convolution, where the brightness values in all channels of each pixel are recomputed based on the values of surrounding pixels. The rules for how each pixel's brightness values should be computed are given by a matrix of numbers, where the central number gives the brightness of the pixel and the other numbers set forth how values from surrounding pixels should be multiplied into the convolution.




Choosing different numbers for the convolution matrix results in a very wide range of visual effects such as sharpening, blur and so on. Manifold provides a 5 x 5 matrix, where each pixel may be adjusted based on reference to 24 surrounding pixels. This convolution matrix will be applied in turn to each pixel in the image.


[List Box]

Choose a preset filter from a list. Choose Custom to create a new filter.


Load the convolution matrix with the numbers for the filter currently shown in the preset box.

Save As…

Save current convolution matrix as a preset filter.


Delete previously-saved preset filter or disable factory preset.

[Matrix boxes]

Values for convolution matrix calculation.


Check to see effect in action.


The list box at the top of the dialog allows choice of a filter from many preset filters. Because there are many presets and because at times very large images may be manipulated in Manifold, choosing a preset does not apply that preset's convolution matrix numbers to the matrix until the Apply button is pressed. This makes it possible to browse the presets without applying their convolution matrix to the main image regardless of whether the Preview box is checked or not.


The Filter dialog has a choice box at the top for preset filter effects. Choosing Custom allows us to enter our own values to create custom filters. In addition to appearing in the Filter dialog, any new custom filters will appear as operators for use in the Transform toolbar.


Creating a Custom Filter


1. Choose custom in the choice box.

2. Enter a value for the center box. This is the brightness multiplication value for the target pixel. Most values used are quite small, almost always less than 20.

3. The boxes surrounding the center box represent pixels surrounding the target pixel. In each box, enter the convolution multiplication value to use for that pixel. For example, to multiply the brightness value by 3 of the pixel immediately to the left of the target pixel, place the number 3 in the box immediately to the left of the center box.

4. Not all boxes need to be filled. Boxes left empty will cause the pixels they represent not to be used for the convolution calculation.

5. Enter the value for scale to be used. Convolution works by multiplying the brightness values of pixels used by the number in their box and then adding up the result. This result is divided by the scale number. Larger scale numbers result in less overall brightness.

6. Enter the value of offset, if any, to be used. The offset number is added to the brightness values computed as a result of the convolution divided by the scale. Positive numbers for offset increase overall brightness. Negative numbers decrease overall brightness.






The following examples all apply different filters to the image of Tokyo airport above, shot from the Landsat 7 satellite.


Difference East




The Difference East filter subtracts values from the West and adds them to the East. This increases the brightness values where an edge difference exists to the East.




Low Pass 1




The Low Pass 1 filter ends up eliminating changes that are only a pixel wide, and so blurs the image. Note how the convolution values surrounding the central value are all the same as the central value. Three different low pass filters provide differing values for the matrix.




"Low frequency" details are those where there is slow change from pixel to pixel. "High frequency" details are those where there is rapid change from pixel to pixel. The "low pass" filters are so named because they allow low frequency changes to pass but block high frequency changes.


High Pass 1




The High Pass 1 filter allows high frequency details to pass and blocks low frequency details.




Note how the image of Tokyo airport has had small changes from pixel to pixel emphasized by the high pass filter. Three different high pass filter presets provide differing matrix values.


Edge Pixel Effects


Because matrix filter effects work by convolution using values that surround a central pixel they raise the question: what to do with pixels on the very edge of the image, where there are no adjacent pixels on one or more sides to participate in the matrix? There are two approaches used by raster image editing packages. One approach is to simply leave pixels on the edge unchanged.




As may be seen above illustration, a zoomed in view of the result of the low pass filter, this is the Manifold method and is also the approach used by most professional image editing packages.


Another possible approach is to apply the matrix effect to edge pixels as if they were surrounded on the "empty" side by black pixels. Manifold does not take this approach because it results in inaccurate effects with edge pixels. If desired, an image can always have a black or other color border drawn about it if such an "approximate" effect is desired for edge pixels. In this way, the Manifold approach allows users to choose how they wish edge pixels to be treated.


5 x 5 Matrices


All preset convolution matrices in Manifold are 3 x 3 matrices: only the central value and the immediately adjacent pixel value boxes have values in them. All other values are zero. Surprisingly, most classic image manipulation effects may be achieved with 3 x 3 matrices.


If desired, we may create filter effects that employ 5 x 5 matrices by filling in the additional boxes with values. This will require longer computation time, but allows finer control over the convolution computation. Filtering with a 5 x 5 matrix that contains zero for boundary values will automatically switch into 3 x 3 mode for better performance (since a 5 x 5 matrix with zeros in the outermost boxes is equivalent to the 3 x 3 matrix that is surrounded by the zeroes).


Continued Education


The above three examples are just three of many filters provided with Manifold. Review of the other filters in the preset list box combined with experimentation using new, custom filters is a good way to learn how various convolution matrix-based filters work.


In addition, there are news groups and lists on Internet in which image manipulation effects are discussed. Participation in such groups and lists together with creative use of a good search engine will provide many sources of information on using and creating convolution matrix filters.