File Exchange

image thumbnail

Fast and Accurate Bilateral Filtering

version 1.1.0.0 (183 KB) by Kunal Chaudhury
Fast and Accurate Approximation of the Bilateral Filter

5 Downloads

Updated 05 Jul 2016

View Version History

View License

This is the MATLAB implementation of the fast approximation of the bilateral filter (for 8-bit grayscale
images) described in the following article:
[1] K. N. Chaudhury, S. Dabhade, ''Fast and provably accurate bilateral filtering'', IEEE Transactions on Image Processing, vol 26, no. 5, pp. 2519-2528, 2016. (arXiv: http://arxiv.org/abs/1603.08109)

Cite As

Kunal Chaudhury (2021). Fast and Accurate Bilateral Filtering (https://www.mathworks.com/matlabcentral/fileexchange/56158-fast-and-accurate-bilateral-filtering), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (16)

William Mantzel

Thank you Kunal for the original implementation and to Ian for this helpful suggestion to use separable filters. I tried it and although it saves "only" about 10-30% small values of spatial sigma, there are substantial savings for sigma > 10 pixels, roughly a factor of N where N = sigma/10. Perhaps even more importantly, it cuts dependencies on unnecessary toolboxes, which is very helpful for me.

Ian's notation doesn't work as is, but here is the updated version with his idea:
https://gist.github.com/willem0/6bae889dda3473439aa77a2a3de98431

(perhaps these changes will make it into the next release)

Kunal Chaudhury

Ian Craig: I tried what you suggested, but the timing didn't change significantly!

Harsha K

Nice. If I have to extend this to 12-bit or 16-bit grey-scale images. What do I have to change in the existing code?

Ian Craig

Very nice. I have one suggestion, though. You can take advantage of the fact that both the Gaussian and box kernels are rank 1 and use `conv(Hs, Hs, im, 'same')` instead of using `padarray` and `imfilter`. In this case, `Hs` would be the one-dimensional version of your filter. For box, it would be `Hs = ones(2*L + 1, 1)/(2*L + 1);` and for Gaussian it would be `Hs = exp(-((L:L).^2/(2*sigmar^2))/(sigmar * sqrt(2*pi));` (a normalized Gaussian). Your operations for each filter step goes way down, you don't have to do the last step where you extract the image from the center of the padding, and you remove the dependency on the Image Processing Toolbox.

Wing Fung Hui

May I ask how can I get one image instead of 3 images in the output?

Rakshit Kothari

Hi Kunal. Excellent submission. There are a few bugs however. It's always the safest to implement your code by assuming your input is normalized between 0 to 1. Increasing the spatial Gaussian sigma, i.e, the size of the filter, causes your data to be "suppressed".
You should also consider providing example operational parameters. Many newbies to IP prefer it if the authors provide a rough range of parameters to play with.

Ashish Uthama

Would this approach extend to RGB images?
Making this change will allow the algorithm to process three planes:
g= T+sigmar*(P(L+1:end-L,L+1:end-L,:) ...
./Q(L+1:end-L,L+1:end-L,:));
However, I am not yet sure how to use the Euclidean distance (I plan to work in the L*a*b space). Continuing to work through the formulations in the paper to see if its easily extensible.

BARKATHULLA N R

hi sir,i need to find the mean sq error(MSE),PSNR, normalised absolute error & histogram of the image for both BOX & gaussian filter.If u have no problem in sharing these codes.I REQUEST you to kindly share it.so, that it will we be helpfull for me.waiting for your reply.
thank you.
barkathulla.
email:barkathullanr@gmail.com

BARKATHULLA N R

good

Uttaran Bhattacharya

Abdolamir

Thanks for the code

Yapeng Tian

Thanks for your code!

deba

Sanyuja

Thanks for the code. I appreciate your hard work!! its easy to understand and use.

Very nice! thanks for sharing

Swapnil Dabhade

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!