Bilateral filter
A bilateral filter is a non-linear, edge-preserving, and noise-reducing smoothing filter for images. It replaces the intensity of each pixel with a weighted average of intensity values from nearby pixels. This weight can be based on a Gaussian distribution. Crucially, the weights depend not only on Euclidean distance of pixels, but also on the radiometric differences. This dual dependency preserves sharp edges while suppressing noise.
Definition
The bilateral filter is defined asand normalization term,, is defined as
where
The weight is assigned using the spatial closeness and the intensity difference. Consider a pixel located at that needs to be denoised in image using its neighbouring pixels and one of its neighbouring pixels is located at. Then, assuming the range and spatial kernels to be Gaussian kernels, the weight assigned for pixel to denoise the pixel is given by
where σd and σr are smoothing parameters, and I and I are the intensity of pixels and respectively.
After calculating the weights, normalize them:
where is the denoised intensity of pixel.
Parameters
- As the range parameter σr increases, the bilateral filter becomes gradually equivalent to Gaussian blur; i.e. σd becomes dominant, because the gaussian kernel is then mostly flat.
- As the spatial parameter σd increases, the larger features get smoothened.
Limitations
- Staircase effect – intensity plateaus that lead to images appearing like cartoons
- Gradient reversal – introduction of false edges in the image.
Implementations
implements a bilateral filter in its surface blur tool.GIMP implements a bilateral filter in its Filters → Blur tools; and it is called Selective Gaussian Blur. The free G'MIC plugin Repair → Smooth for GIMP adds more control.
A simple trick to efficiently implement a bilateral filter is to exploit Poisson-disk subsampling.
OpenCV implements the function:
bilateralFilter.Related models
The bilateral filter has been shown to be an application of the short time kernel of the Beltrami flowthat was introduced as an edge preserving selective smoothing mechanism before the bilateral filter.
Other edge-preserving smoothing filters include: anisotropic diffusion, weighted least squares, edge-avoiding wavelets, geodesic editing, guided filtering, and domain transforms.