About Filters
Most filters are either Convolution filters or Morphological filters. Convolution filters are based on a simple processing routine: the software replaces the given value of each pixel in the image with a new value that represents a weighted average of pixels in its vicinity. The replacement pixel is called the offset, and the pixels surrounding it are called the neighborhood. Together they make a kernel. In the following example, the offset, shown in gray, is in the center of a 3x3 kernel. The pixel neighborhood is shown in white.
The value the software assigns to the replacement pixel is a weighted average of some or all of the pixel values in the kernel. By varying the significant pixels (those that get included in the average), and by varying the weighting given to significant pixels, a wide range of filter effects can be achieved. For example, the following represents a kernel that replaces the center pixel’s intensity value with a straight average of all pixels in the kernel. Every pixel in the kernel is included in the average, and each is given an equal weighting.
This kernel creates a simple blurring effect when applied to an image. You could, however, decrease the amount of blur effected by increasing the weighting given to the center pixel. The following would cause the resulting replacement value to have less deviation from the original value because the original value is given greater weight in the average.
Very different effects can be achieved by giving some pixels negative weighting in the average. Consider the following kernel:
This tells the software to replace the center pixel with a value obtained by subtracting the lower right pixel’s intensity value from the upper left pixel’s intensity value. This kernel is the basis for the ‘sculpture’ filter effect.
Negative weightings introduce the possibility of more complicated calculations. For example, the following example gives positive weight by a factor of 2 to the corner pixels while subtracting the other pixels in the neighborhood by a factor of 1.
The replacement value for the center pixel of this kernel would be calculated as follows:
(2a + 2b + 2c + 2d – w – x – y – z) / (2 + 2 + 2 + 2 – 1 – 1– 1 – 1)
The averaging routine that performs such calculations to determine replacement pixel values is the core of convolution filters. Morphological filters, on the other hand, use other methods of determining the replacement pixel value. For the sake of customization, Image-Pro provides four morphological filters: Erode, Dilate, Open, and Close.
Erode - Erodes the edges of bright objects, and enlarges dark objects.
Dilate - Dilates bright objects, and erodes dark objects.
Open - Smooths object contours, separates narrowly connected objects, and removes small dark holes.
Close - Fills gaps and enlarges protrusions to connect objects that are close together.
As with Convolution filters, you can impact the results of the filter by defining the kernel. In the case of Morphological filters, however, you typically only modify kernel definitions to give them different sizes and shapes. For example, the following 5x5 kernels reflect some basic geometric shapes that could be passed to the morphological filters to achieve different effects: