Operations: Bilateral filter

From ILWIS
Jump to: navigation, search
Main Page Arrow.png Operations
Bilateral filter
Bilateral filter

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)


Figure 1, Bilateral filter operation form


To start the Bilateral filter operation from ILWIS main window:

Mar.jpg
  • Click the Operation tab on toolbar tabs
  • From the opened operation list select Bilateral filter


Once the Bilateral 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.
radius pixel neighborhood: Enter a diameter (d) of each pixel neighborhood that is used during filtering. If it is non-positive, it is computed from sigma space .
sigma color: Enter a value to be used for filter sigma in the color space (σr). A larger value means that farther colors within the pixel neighborhood will be mixed together, resulting in larger areas of semi-equal color.
sigma space: Enter a value to filter sigma in the coordinate space (σd). A larger value means that farther pixels will influence each other as long as their colors are close enough. When d>0 , it specifies the neighborhood size regardless of sigma space. Otherwise, d is proportional to sigma space.
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