# Spatial Filter

Navigation:  ProfilmOnline Features > Modifying an Image >

# Spatial Filter

The Spatial Filter operator applies a matrix filter to the surface data. Six filters are available: Median, Mean, Maximum, Minimum, Gaussian, and Laplacian. These filters are used to improve the image or search for certain surface features.

To demonstrate the basic filtering process, we'll use the example matrix below to represent a 5x5 pixel image where the pixel highlighted in gray is the target.

 5 4 7 1 6 5 4 3 6 4 8 7 2 2 5 7 7 9 8 7 4 2 3 1 7

The Mean filter, set for a 3x3 size, uses the average of the surrounding data points to calculate the resulting value. As a result, the sum for the 3x3 grid is 36 (7+1+6+3+6+4+2+2+5) for the 3x3 grid, which is then divided by 9 to give a final value of 4.

The primary uses of all filters and are as follows:

## Median Filter

Removes noise from a surface by arranging the data points in the region of the matrix in order from least to greatest. The middle value of the distribution is then used as the filtered value.

## Maximum Filter

Selects the data point with the maximum value within the matrix region and uses that as the new value. The residual surface created by this filter is often used to find peak outliers on the surface.

## Minimum Filter

Selects the sample with the minimum value within the matrix region and uses that as the new value. The residual surface created by this filter is often used to find valley outliers on the surface.

## Mean Filter

Smooths the surface by averaging each point against its nearest neighbors. The larger the filter matrix size, the larger the smoothing effect.

 Original Image Mean 3x3 Mean 9x9

## Gaussian Filter

Similar to the Mean filter in that it is used to smooth the data. However, instead of using the average value it will apply a Gaussian matrix kernel. An example of the 3x3 matrix kernel is shown below.

 1 2 1 2 4 2 1 2 1

## Laplacian Filter

Detect sharp transitions in the surface data. An example of the 3x3 matrix kernel is shown below.

 -1 -1 -1 -1 8 -1 -1 -1 -1

The available filter sizes are 3x3, 5x5, 7x7, 9x9 and 13x13. In general, the larger the filter size the greater the filter effect. The Smoothed Image is the result of the Noise Image subtracted from the Starting Image. The Noise Image contains the surface detail to be removed by the filtering process. Select which image to output using the radio buttons below the images. The Smoothed Image is selected by default.

Once the Filter Method, Filter Size, and output image have been selected, click OK to apply the filter to the scan.