FILTER

FILTER

Applies a filter to an image

Syntax

filter-type
must be specified as `'CONVOLUTION'`. Other filter types will be added in the future.

Type: Character

matrix
contains the matrix size, the filter matrix, the divisor, the bias, and 1 if you want to use the absolute value of the resulting value. If not specified, the defaults are 1 for divisor, 0 for bias, and 0 for not using the absolute value. Separate each number with a space.

Type: Character

The FILTER command supports convolution filters that are provided by users. A filter matrix is moved along the pixels in an image, and a new pixel value is calculated and replaced at the pixel that is at the center point of the filter matrix. The new value is determined by weighting nearby pixels according to the values in the filter matrix.

A detailed explanation of the concept and theory behind filtering is beyond the scope of this document. However, it is explained in many textbooks. For example, see Digital Image Processing, by Rafael Gonzalez and Paul Wintz, and The Image Processing Handbook, by John C. Russ.

The equation that FILTER uses is shown in Calculating New Pixel Values.

Consider the following 3x3 matrix:

```-1 -2 -3
4  5  6
-7  8 -9 ```
Design the matrix with a divisor of 1 and a zero bias, and use the absolute value of the answer:
```matrix="3 -1 -2 -3 4 5 6 -7 8 -9 1 0 1";
rc=imgop(tid,'FILTER',"CONVOLUTION",matrix);```

Note:   Calculated values that are larger than 255 are normalized to 255, and calculated values that are smaller than zero are normalized to zero. If 1 is set for 'absolute value', then negative numbers are converted to positive numbers before normalization.

A filter selection and creation window is available. An example of using it is in the image sample catalog (imagedmo) named FILTEXAM.FRAME. It is essentially the same window that is used in the Image Editor. It accesses the filters that are shipped with the Image Editor.