Pixopedia Documentation

Print

5.4. Simple 3×3 Filters

Simple 3×3 Filters (menu entry: Actions->Simple 3×3 Filters).

This action performs simple image filtering with 3×3 kernel using various modes. You can use predefined filters, a set (examples) of user defined filters or you can create your own filters and save them. All user defined filters are saved in userdef_xml folder with extension .flt. Note: user defined filters are shown in italic/cursive font.

All filters (predefined and user defined) have following additional options:

Filter options

  • Wrap border: if checked, when sliding kernel encounters image border, pixels from the opposite side of the image will be used.
  • COI (channels of interest – Red, Blu, Green): filtering will be performed only on channels checked.
  • Filter code: actual filter mode, kernel, div and bias. When you double-click inside this area (memo field) a new window will pop-up. Here you can change filter parameters and save the filter as user defined.

So, how the filtering is performed?

First, depending on filter’s mode each kernel value is combined with respective image pixel value (in case of linear mode, values are multiplied). After this step, all resulting values are summed and divided by div value and finally bias value is added.

As you may notice from the example/image above (Soften filter), mode is linear, i.e. simple convolution…actually cross-correlation (to be more precise) is performed with specified kernel. The result of this linear filtering is divided by 17 and zero bias is added.

Anyway, here is the formula (just to test LaTex expression) for 3×3 cross-correlation filter for pixel at position i,j (I – image, K – kernel) :

    \[J(i,j) = \sum_{u=-1}^{1}\sum_{v=-1}^{1}I(i+u,j+v)K(u,v)\]

and we replace current pixel with:

    \[I(i,j) = \frac{J(i,j)}{div}+bias\]

Here is a list of filter modes:

  • linear: simple cross-correlation (as described above).
  • closest: this type of filter is performed in two steps: first, simple cross-correlation is calculated and divided by div value. In the second step, 3×3 neighbor is checked and pixel’s channel closest to cross-correlation value replaces all channels in resulting pixel.
  • maxdiff: while performing kernel-neighbor multiplication,  we pick maximum difference between current value and central/midpoint value. Midpoint value is subtracted from max-diff value, divide by div, incremented by bias and saved as result.
  • minmax: simple cross-correlation is calculated together with maximum and minimum channel values. min/max value closest to cross-correlation value is used as a result (div and bias applied to result value).
  • binlogic: bit-wise logical operation is performed between kernel  and respective pixel. Resulting values are summed, divided by div and incremented by bias.

Note: once again, to create your own filter, double-click with your mouse somewhere in filter code to invoke new pop-up window, where you can write your own filter and save it under some name. The text written in description field will be shown in filters list.