# Comparison Between Guided Filter (Edge Preserving Filter) and Gaussian Filter

I am looking for a good example that showing the different between Guided and Gaussian Filters. The example need to show the benefit of Guided filter, (for example: preserving edge...). Could you give me some example for that task? Thanks in advance

I tried some example, but it did not show benefit of Guided comparison with Gaussian

% example: edge-preserving smoothing
% figure 1 in our paper

close all;

I = imnoise(I,'gaussian',0.1,0);
p = I;
r = 4; % try r=2, 4, or 8
eps = 0.2^2; % try eps=0.1^2, 0.2^2, 0.4^2

q = guidedfilter(I, p, r, eps);
std_Gb=1;
beta=0.1;
%% Initialization
Ng=ceil(3*std_Gb)+1; Gaussian = fspecial('gaussian',[Ng Ng],std_Gb);
imsm = conv2(I,Gaussian,'same');

Gb1 = 1./ (1 + 1* NormGrad.^2);

Gb2= 1./ (1 + 1* NormGrad.^2);

figure();
subplot(2,1,1);imshow([I, q,imsm],[]);
subplot(2,1,2);imshow([Gb1,Gb2],[]);


1. Create a synthetic image with abrupt change form black to white (Better yest from Dark Gray to Bright Gray).
2. Add Gaussian Noise to it.
3. Filter it with Guided Filter and Gaussian Filter.
4. Look at the results.
5. Draw a 1D Line which crosses it and look at the Original, Noisy, Filters Guided, Filtered Gaussian.

Here are the results:

Noisy Image

Gaussian Filtered Image

Guided Filtered Image

As one could see, the Gaussian Filter smooth the image across high contrast edges while the Guided Filter keep the edges.

The MATLAB code is available at my StackExchange Signal Processing Q29041 GitHub Repository (Look at the SignalProcessing\Q29041 folder).

– Jame
Feb 26, 2016 at 12:44
• I added MATLAB Code and visualization. Enjoy...
– Royi
Feb 26, 2016 at 16:35
• It is really good ans. Could you suggest to me how can I choose the radius and var. para. of Guided filter when noise increasing? Does it still has benefit for other kind of noise or just Gaussian noise?
– Jame
Feb 26, 2016 at 17:08
• The larger the radius, you can deal with lower frequency noise. Basically, it will work pretty good with any White Noise (Assuming it has Zero Mean).
– Royi
Feb 27, 2016 at 13:14
• Thank you. If I consider Gaussian noise with (zero mean, and variance v), then lower frequency noise means low variance v. Is it right?
– Jame
Apr 2, 2016 at 7:26