The Bilateral filter is a nonlinear filter that reduces noise and smooth an image while preserving edge structures. It combines gray levels or colors based on both their geometric closeness and their photometric similarity, preferring near values to distant values in both aspects. In other words, the output of the filter is controlled by two parameters: σd (spatial parameter) and σr (range parameter). The operation examines the intensity value at each pixel in an image and replace them with a weighted average of intensity values from neighboring pixels. The weights depend not only on Euclidean distance of pixels, but also on the radiometric differences such as: color intensity and depth distance. The weight values are adjusted through learning process by systematically looping through each pixel and its neighboring pixels.
Note that small (< 10) σ parameters reduces the filter effect, whereas the larger (> 150) value introduce a very strong effect, making the image look “cartoonish”. The size of the filter (d) impacts its performance in term of time required to complete the operation; meaning large filters (d > 5) are very slow. It is recommended to use d=5 for real-time applications, and perhaps d=9 for offline applications that need heavy noise filtering.
The Bilateral filter operation is adapted from OpenCv library where you will find more detail information concerning the filter algorithm and its applications.
The Bilateral 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 radius pixel neighborhood (d), sigma color value (σs), sigma space value (σr))
Then, the Python syntax for the above mentioned operation is:
output raster = ilwis.Engine.do("bilateralfilter", “file:///C:/mydir/myraster.mpr", d, σs, σr)
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("linearrasterfilter", rc, d, σs, σr)