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)