Pixopedia_24 Tutorial   3x3 Filters
  Index page      
  Previous page

3x3 Filters (Simple 3x3 filters) is a set of actions that combines each pixel of an image with surrounding pixels. Combining is perform through a kernel which is a 3x3 matrix. Beside standard convolution technique, there are four more modes of pixel combining techniques.

  Next page
   
   

Filters
By pressing this button (pressed by default), a listbox with predefined 3x3 filters is shown. When you choose desired filter, 3x3 kernel is filled with chosen filter values. The field Div is filled with division value and field Bias is filled with bias value. Also, appropriate mode is selected inside the mode listbox.

User
By pressing this button, a listbox with user defined 3x3 filters is shown. Heree you can find your own filters (if any) you have previously created and saved by Save button. All fields are filled and filter mode is also seleced.

Save
Use this action to save your newly created filter. After all desired values for 3x3 kernel, division factor, bias are entered and mode selected (a small listbox in upper left corner), try your filter on current image. If you want to save this filter as user defined, simply press this button. A dialog box appears. You need to enter the filter name and click button OK. A new user defined filter is available for future use.

How the filter works ?
Now, we are going to discuss how the 3x3 filter work in each mode.

  • Linear filter (convolution) is the simplest mode of 3x3 filter available. Each pixel of the image iz scanned with it's neighbor pixels. Each of those nine pixels is multiplied by value of respected element in kernel (matrix). Result elements are summed and result of addition is divided by Div factor. After that, Bias value is added. For more details see convolution operation in digital image processing.
  • Cl. Color filter (closest color) works in the same way as linear (convolution) method, except that after obtaining result, search is performed over neighborhood to find pixel that has the closest color value to resulting pixel.
  • Difference filter works in a way that after kernel multiplication maximum difference from middle element is calculated. Result is again divided by Div and Bias is added.
  • MinMax filter works like difference filter, except that maximum and minimum pixel is searched. After calculating absolute difference from middle element, pixel having higher resulting value is stored as resulting pixel.
  • ArithBool filter (arithemetic-boolean) is different then previous filters, because it combines Foreground color with 3x3 kernel. First, middle pixel is combined with foreground color via some arithmetic or boolean operation. The result is stored. After that, each element of kernel matrix is combined with that result. After every operation the result is stored for new operation. Div and Bias are applied at the end.

 


Kernel Values for ArithBool Filter
In ArithBool filter, values in kernel fields are not values used for multiplication, but they are used to choose which operation among pixels is to be performed. Here is the list of valid values:

  • 0 - this value means NOP, i.e. value of that pixel is stored as result value.
  • 1 - XOR operation.
  • 2 - AND operation.
  • 3 - OR operation.
  • 4 - ADD operation (addition).
  • 5 - SUB operation (subtraction).
  • 6 - cADD operation (circular addition).
  • 7 - cSUB operation (circular subtraction).
  • 8 - sADD operation (swap addition).
  • 9 - sSUB operation (swap subtraction).
  • 10 - MULT operation (multiply).
  • 11 - MOD operation (modulo).
All other values are treated as 0 (NOP) operation.
Putting the minus sign infront of values above, pixel inversion is performed prior to operation specified.

Wrap checkbox specifies whether wrapping occurs when scanning kernel encounters image border. When checked, wrapping is performed.

To learn more about arithmetic and boolean operations, refer to Image Shifting or Drawing sections.

Applying 3x3 Filter
If you want to apply 3x3 Filter on whole image, after choosing the filter or entering your own parameters, simply press Image button. Filter will be applied to whole image.

You can apply 3x3 Filter through brush movement, contour and mask as well. For shape selection and brush movement refer to
Shapes and Brushes section.

NOTE:
Resultant image is affected by all previously set
Global parameters.
All kernel elements that are beyond the image border are wrapped around if Wrap is checked.

NOTE:
Simple 3x3 filters are not fast as IPL filters or Convolve 7x7 filters which use glittering fast Intel Image Processing Library, but as some effects can not be obtained with those two filter sets, 3x3 filter set is introduced.


Example of using 3x3 filters. In the upper left corner is original picture, other pictures are processed by 3x3 filters. Click on picture to enlarge.