4.6

4.6 | 15 ratings Rate this file 179 downloads (last 30 days) File Size: 118.21 KB File ID: #12191

Bilateral Filtering

by Douglas Lanman

 

06 Sep 2006

Code covered by BSD License  

Implements bilateral filtering for grayscale and color images.

Download Now | Watch this File

File Information
Description

Bilateral filtering was proposed by Tomasi and Manduchi in 1998 as a non-iterative method for edge-preserving smoothing. For a complete description see the following publication:

C. Tomasi and R. Manduchi. Bilateral Filtering for Gray and Color Images. In Proceedings of the IEEE International Conference on Computer Vision, 1998.

This package contains a basic implementation (bfilter2.m) of their method for both grayscale and color images. In order to demonstrate the utility of bilateral filtering, the main function is used to implement an automatic image abstraction routine (cartoon.m) inspired by:

Holger Winnemoller, Sven C. Olsen, and Bruce Gooch. Real-Time Video Abstraction. In Proceedings of ACM SIGGRAPH, 2006.

A demonstration program (runDemo.m) summarizes the typical use of all included files.

A gallery of image and video abstraction results is available at: http://mesh.brown.edu/dlanman/photos/Bilateral

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Color Space Converter

MATLAB release MATLAB 7.3 (R2006b)
Zip File Content  
Other Files Bilateral Filtering/academy.jpg,
Bilateral Filtering/bfilter2.m,
Bilateral Filtering/cartoon.m,
Bilateral Filtering/colorspace.m,
Bilateral Filtering/einstein.jpg,
Bilateral Filtering/mandrill.jpg,
Bilateral Filtering/runDemo.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (16)
15 Nov 2006 Ido Omer  
04 Dec 2006 Wenjing Jia

Very easy to understand and use! Comments precede each part. Run perfectly!

21 Mar 2007 Tom Pinkiewicz

Great filter but rather slow.
Do you know if it can be vectorised or sped up in some other way?
If there is anyone out there that knows how to speed up this code please let me know.
Good work!

30 Aug 2007 Yulia Monich  
10 Oct 2007 anup pandey  
27 Oct 2007 Zhi Zhang

Excellent method except the speed. But a lot of papers are coming out. You can go to the SIGGRAPH07 for some information.

21 Nov 2007 kanch K  
18 Dec 2007 sethu madhavi  
18 Jan 2008 Seong Park

good

29 Apr 2008 Daniel Oldjira Fufa

Thanks for the code

02 Jul 2008 Giljin Jang

Thanks for the hard work. I appreciate the code.

16 Jul 2008 DO Quoc Bao

Thanks alot :)

06 Aug 2008 Frederic Garcia

First of all, thank you for the code but, according to the Tomasi and Manduchi paper, I think that instead of:

G = exp(-(X.^2+Y.^2)/(2*sigma_d^2));

it should be:

G = exp(-(X-Y).^2/(2*sigma_d^2));

with respect to the GausSian distance weight in the bfilter2.m file.

Please, correct me if I'm wrong.

Bests,

06 Aug 2008 Douglas Lanman

Frederic,

Thank you for your comments. I believe the code you referred to, specifically lines 67 and 114 in bfilter2.m, is correct as written. These lines implement the c(\xi,x) equation from Section 2.1 from the Tomasi and Manduchi paper. As they state, c is radially symmetric, with the d(\xi,x) term corresponding to the Euclidean distance between \xi and x. Expanding these expressions, the numerator of the exponent should be -(X.^2+Y.^2), not -(X-Y).^2. Your concern might come from how I've used the G matrix on these lines. This matrix is used to pre-compute c(\xi,x) for a w-by-w sized window. In this case, the origin is always the center pixel, so \sqrt((X.^2+Y.^2)) will represent the Euclidean distance of a pixel from the center of the window, where X and Y are pixel coordinates with respect to the center pixel, i.e. as given on lines 66 and 113. These geometric terms are identical for all windows, which is why I pre-computed their values. Unfortunately, the "intensity similarity" will vary for each w-by-w window. As a result, the H matrix, as given by lines 87 and 140, must be evaluated independently using a "sliding window" analysis.

Please send me an email if you have any further questions about my implementation.

Best regards,
Doug

17 Dec 2008 Hani Jamleh  
08 Feb 2009 Arun Kesavan

First of all, thank you for the code but, while using with mat lab 7.0 , i am getting errors
as

??? Error: File: Z:\Bilateral Filtering\bfilter2.m Line: 29 Column: 1
Function definitions are not permitted at the prompt or in scripts.

Error in ==> runDemo at 30
bflt_img1 = bfilter2(img1,w,sigma);

please tell me how to use your code?

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
filtering Douglas Lanman 22 Oct 2008 08:37:37
bilateral filter Douglas Lanman 22 Oct 2008 08:37:37
image abstraction Douglas Lanman 22 Oct 2008 08:37:37
cartoon filter Douglas Lanman 22 Oct 2008 08:37:37
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com