2D Convolution

Overview

This program convolves (replaces each value with a weighted sum of the surrounding pixels) each section with a two-dimensional kernel (the rectangular array of weights). The kernel can be chosen from a list of common kernels or can be loaded from a file; in either case, the kernel can be interactively edited. The algorithm does not employ Fourier transforms, and pixels where the summation would extend past the boundaries of the section are assigned the value from the nearest pixel where the summation completely fell within the section.

Topics

Overview | Dialog | Kernels | Size | Format |

Related Priism Topics

Priism | Categories | Applications |


Selecting a Kernel

The text field next to this button shows the title of the currently loaded kernel. Use the pink button labeled "load kernel" to access a menu to load one of the default kernels or to load a kernel from file. The green button labeled "view/edit kernel" will open a dialog that allows you to manipulate the current kernel. With it, you can save the kernel to a file, resize it, or change individual values (any changes to individual values become effective immediately).

Topics

Overview | Kernels | Dialog | Size | Format


Resizing a Kernel

To resize the kernel, first view the kernel using the "view/edit kernel" button in the main dialog. Then depress the "change size/precision" button in the dialog that is opened. The size of the kernel is specified by the X and Y half-widths: the kernel has (2*x Half-width + 1) columns and (2*Y half-width + 1) rows. The decimal places field specifies how many decimal places are shown on kernel values when the kernel is viewed or saved to a file. After changing the size and precision values, depress the "apply" button to resize the kernel. When the kernel is resized, the center of the existing kernel is preserved. Where the new kernel extends beyond the old, zeroes are used to fill the missing values.

Topics

Overview | Dialog | Kernels | Size | Format


Kernel File Format

The file format used for kernels saved to file is

        <title><newline>
        NX=<int><whitespace>NY=</int><whitespace>PREC=<int><newline>
        <float array>

The definitions of the individual components are

        <title>       100 or less characters
        <int>         a base 10 integer value
        <whitespace>  one or more tabs or spaces.
        <float array> consists of ny <float lines>
        <float lines> is nx floats separated by <whitespace>

When the convolution is performed on a pixel, p, on a section, it corresponds to the following operations with the array stored in the file:

  1. flip the array horizontally and then vertically center the flipped array (the center of the flipped array is the element in column (nx-1)/2 and row (ny-1)/2 where the rows are and columns are numbered from 0) at pixel p in the section (where the section is layed out as it is displayed on the screen)
  2. multiply each value in the flipped array with the corresponding element in the section. The sum of these multiplications is the result at pixel p.

The list of default kernels used by the NewConvolution program is read from the file NEWCONVOLUTION_FILTERS located in the CONFIG directory of the IVE hierarchy. The format of this file is

        NUM_KERNELS=<int><newline>
        <kernel description>

where <kernel description> has the same format as the individual kernel files described above.

Topics

Overview | Dialog | Kernels | Size | Format