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 (e.g., range differences, such as color intensity, depth distance, etc.). This preserves sharp edges.
Definition.
The bilateral filter is defined as
and normalization term, formula_2, is defined as
where
The weight formula_12 is assigned using the spatial closeness (using the spatial kernel formula_11) and the intensity difference (using the range kernel formula_10). Consider a pixel located at formula_15 that needs to be denoised in image using its neighbouring pixels and one of its neighbouring pixels is located at formula_16. Then, assuming the range and spatial kernels to be Gaussian kernels, the weight assigned for pixel formula_16 to denoise the pixel formula_15 is given by
where σd and σr are smoothing parameters, and "I"("i", "j") and "I"("k", "l") are the intensity of pixels formula_15 and formula_21 respectively.
After calculating the weights, normalize them:
where formula_23 is the denoised intensity of pixel formula_15.
Limitations.
The bilateral filter in its direct form can introduce several types of image artifacts:
There exist several extensions to the filter that deal with these artifacts, like the scaled bilateral filter that uses downscaled image for computing the weights. Alternative filters, like the "guided filter", have also been proposed as an efficient alternative without these limitations.
Implementations.
Adobe Photoshop 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 [bilateral]" for GIMP adds more control.
A simple trick to efficiently implement a bilateral filter is to exploit Poisson-disk subsampling.
Related models.
The bilateral filter has been shown to be an application of the short time kernel of the Beltrami flow
 that 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, iterative guided filtering and domain transforms.