Real-time Bilateral Filtering
17 May 2017Many users have become accustomed to reducing wrinkles, freckles, and various blemishes from human subjects for a more visually appealing image or video.
To solve this problem, an effective way is to apply an edge-preserving filtering called bilateral filter. However, a vanilla bilateral filter has a high computational cost necessitating a powerful CPU / GPU to process full HD images in real-time. So I had been looking for an efficient alternative algorithm, and finally found
Yang, Qingxiong. Recursive bilateral filtering. European Conference on Computer Vision 2012.
that can achieve a good trade-off.
I made a lightweight C++ library for this algorithm, and obtained the following results (RecursiveBF):
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
Original Image | OpenCV’s BF (896ms) | RecursiveBF (18ms) | Gaussian Blur | Median Blur |
The algorithm is pretty fast compared with most edge-preserving filtering methods
- computational complexity is linear in both input size and dimensionality:
- takes about 43 ms to process a one megapixel color image (i7 1.8GHz & 4GB mem)
- about 18x faster than Fast high-dimensional filtering using the permutohedral lattice
- about 86x faster than Gaussian kd-trees for fast high-dimensional filtering
For more details of the algorithm, please refer to the original paper.