Bilateral Filter is a very famous denosing filter which not only could denoise and smooth the images but also could preserve the edge. The most easily understand illustration could be demonstrated as Fig 1. You could see from the illustration here, Bilateral Filter not only consider the spatial distance, but also will consider the pixel intensity distance. By that way, it could achieve edge-preserving denoising filter, which Gaussian filter cannot achieve.
Fig 1. The illustration for Bilateral Filter
So, the bilateral filter only with advantages but not disadvantages? The answer is No!!! Although the edge-presering property is really nice, however, since the nonlinearality inherent in the bilateral filter, it is very slow to implement bilateral filter. What is the Nonlinearality? Let’s compare bilateral filter with Gaussian filter, the Gaussian filter could be formulated as below:
$$ I_{p}^{gf} = \frac{1}{W_{p}^{gf}}\sum_{q\in s}G_{s}(||p-q||2^2)\cdot I{q} $$
where $W_{p}^{gf}$ is the normalization constant;
And bilatera filter could be expressed as:
$$ I_{p}^{bf} = \frac{1}{W_{p}^{bf}}\sum_{q\in s}G_s(||p-q||_2^2)\cdot {\color{red}G_r(|I_q - I_p|)} \cdot I_q $$
where $W_p^{bf}$ is the normalization constant as well.
$$ W_p^{bf} = \sum_{q\in s}G_s(||p-q||_2^2)\cdot G_r(|I_q - I_p|) $$
The most significant difference is point out by red text, which represent the filter not only take the spatial distance into account, but also will consider the intentsity diffenrence, the intensity difference too large, then the weight for that pixel will be very low! The nonlinearality comes from two aspects:
Since they are directly related with pixel intensity.
Nonlinearality will result in what problems? The most severe part is about the running time of the filter; For normal Gaussian filter, we could pre-compute the convolution kernel as it only related to the relative spatial relationship, and for two-dimensional case, the 2D convolution could be seperated into two 1D convolution which could be accelerated by FFT algorithm;
Strongly recommend reading the original paper: A Fast Approximation of the Bilateral Filter using a Signal Processing Approach by Sylvain Paris and Fr ́edo Durand;