Operations: Box filter

Jump to: navigation, search
Main Page Arrow.png Operations
Box filter
Box filter

In general, the box filter is a type of smoothing filter that used to soften an image by reducing noise and detail. The box filter is different from the other ILWIS standard smoothing filters since it always uses value of 1 as the kernel coefficients, its kernel size in term of width and height can be any odd/even values and it allow user to use a gain factor of 1 or a normalized gain factor 1/width * height of kernel.
The function box filter smooths an image using the kernel:


The Box filter operation is adapted from OpenCv library where you will find more detail information concerning the filter algorithm and its applications.

The Box filter operation can be applied either via ILWIS-Python editor or via ILWIS Main window, Toolbar and the Operatins tab. The required Python syntax is:

name of the output raster coverage = ilwis.Engine.do(name of the operation, name of the input raster coverage, a value for kernel width(w), a value for kernel height (h), normalized)

Then, the Python syntax for the above mentioned operation is:

output raster = ilwis.Engine.do("boxfilter", “file:///C:/mydir/myraster.mpr", w, h, normalized = true or false)

In general, the URL used in the Python syntax can be replaced with variable name created using Python. For example: you can open a feature coverage as a variable and give it a name as the following example:

rc = ilwis.RasterCoverage("file:///C:/mydir/myraster.mpr")

Once the variable is created, then it can be used directly in Python syntax without quotation mark and the path as the following:

output raster = ilwis.Engine.do("boxfilter", rc, 5, 4, true)

Figure 1, Box filter operation form

To start the Box filter operation from ILWIS main window:

  • Click the Operation tab on toolbar tabs
  • From the opened operation list select Box filter

Once the box filter operation is selected from the list, an operation form will be opened in which you can set parameters required for that operation including input(s), output(s), memory location and data format (Figure 1).

To successfully execute this operation, you need to complete the form with proper inputs data. The inputs data must be dragged from the catalog and dropped in their corresponding fields in the form or typed in.

raster coverage: Select an input raster coverage to be filtered.
kernel width: Enter a value for the width (w) of the kernel to define number of neighboring pixel in x direction.
kernel height: Enter a value for the height (h) of the kernel to define number of neighboring pixel in y direction.
normalize: Select yes to normalize the sum of the kernel pixel values to the total number of kernel cells. Select No to use the sum of kernel pixels values in the output filtered map.
output raster coverage: Type a name for the output raster map that will contain results of the filtering operation.
Output format: Select a format to save the output raster map. The default format is Memory; if you select it, the output will be temporally saved in the internal catalog and will be removed when you exit the program. If you select other format, the output will be saved in the active catalog.
Execute: Click the Execute button to run this operation.

Detailed information on filtering and the available standard filter in ILWIS are given in: Basic concept: Filters