3x3 Convolution

Use the Grid and Image > Filters > 3x3 Convolution menu option (GRIDFILT GX) to apply a 9-point filter to a grid using any number of passes.

3x3 Convolution dialog options

Input grid file

File Name of the Input Grid. (.grd file)

Script Parameter: GRIDFILT.GRD

New resultant grid

File Name of New Grid. (.grd file)

Script Parameter: GRIDFILT.NEW

OPTION 1 - Select a predefined filter

Name of pre-defined 9 point filters.(option 1 of 3)

Options are:

  • None

  • Hanning (default)

  • Laplace

  • Horizontal derivative X direction

  • Horizontal derivative Y direction

  • Horizontal derivative 45 degrees

Script Parameter: GRIDFILT.DEFFILT

OPTION 2 - Choose a 9-point filter file

Name of file containing 9 point filter. (option 2 of 3)

Script Parameter: GRIDFILT.FILT

OPTION 3 - Type a 9-point filter string

9 Point filter string - 9 comma delimited numbers: e.g. 1,2,3,4,5,6,7,8,9 (option 3 of 3) * If none of the above parameters are set, the GX will default to using the HANNING filter!

Script Parameter: GRIDFILT.FILTSTR

Number of passes to apply

Number of filter Passes to apply to create the new grid (default =1).

Script Parameter: GRIDFILT.PASS

Multiplier to apply to grid values

Multiplier to apply to the grid (default = 1.0)

Script Parameter: GRIDFILT.MULT

Result if any grid dummies within filter

If "INTERPOLATE", dummies are replaced by interpolated values, except for the center value if it is a dummy. If "DUMMY", the grid will have a dummy if any of the grid values in the filter are dummy or outside of the grid. The default setting is "INTERPOLATE".

Script Parameter: GRIDFILT.DUMMY

Application Notes

The 9-point filter consists of a 3X3 convolution matrix. This type of filter is used extensively in image processing applications.

There are three options to choose when defining the filter:

  1. You can enter the name of a pre-defined filter in the .DEFFILT parameter; or,
  2. Enter into the .FILT parameter the name of a filter file you have created; or,
  3. You can enter the 9 points of the filter as a command delimited string into the .FILTSTR parameter.

Pre-defined filters:

Hanning:

0.06

0.10

0.06

Laplace:

0

-0.25

0

0.10

0.36

0.10

-0.25

1

-0.25

0.06

0.10

0.06

-0.25

0

 

 

 

 

 

 

 

 

Horiz.Deriv.

45 Degrees

0

1

0

Horiz.Deriv.

X Direction

0

0

0

-1

-1

0

1

0

-1 

0

0

0

 

 

 

 

 

 

 

 

Horiz.Deriv.

Y Direction

0

1

0

 

 

 

 

0

0

0

 

 

 

 

0

-1

0

 

 

 

 

A filter file contains the 9 filter coefficients starting with the top row, listed left to right, then continued with successive rows listed left to right. (e.g. the Horizontal Derivative Filter in the Y Direction is: 0,1,0,0,0,0,0,-1,0 ) There cannot be any spaces within or between numbers, and the numbers themselves must be real numbers in the range of-1e31 to 1e32.

If you enter the 9 points as a string, then enter them just like the above filter file format, using commas to delimit the values.

Applying 9-Point Filters

You can use the GRIDFILT GX to apply a 9-point Hanning filter to a grid any number of times. The Hanning filter is a smoothing filter defined by the 3x3 point kernel filter shown above.

 The GRIDFILT GX is most commonly used to smooth a grid immediately before contouring in order to improve the cosmetic appearance of the contours. In this application, 1 to 3 passes are usually sufficient.

Another useful application is to produce a curvature grid. To do this, the Hanning filter is passed once over a grid and the result is subtracted from the original grid (using the Grid Math Expression Builder). This residual is proportional to the curvature in the original grid, with zero values indicating inflection points. The curvature grid may be subsequently filtered with GRIDFILT in order to smooth noise.

Additional Notes

  • At the edges of valid data, only those coefficients, which occupy a valid point are used, and the filter is normalized to 1.
  • We do not recommend passing the filter more than 5 times. If additional smoothing is required, a better approach is to decimate the grid, filter and then re-sample at the required grid resolution.