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 = double(imread('.\img_smoothing\cat.bmp')) / 255;
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);
%% Initialization 
Ng=ceil(3*std_Gb)+1; Gaussian = fspecial('gaussian',[Ng Ng],std_Gb);
imsm = conv2(I,Gaussian,'same');

[Gx,Gy] = gradient(q );
NormGrad = sqrt(Gx.^2 + Gy.^2); 
Gb1 = 1./ (1 + 1* NormGrad.^2);

[Gx,Gy] = gradient(imsm);
NormGrad = sqrt(Gx.^2 + Gy.^2); 
Gb2= 1./ (1 + 1* NormGrad.^2);

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

enter image description here


1 Answer 1

  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

Noisy Image

Lines - Noisy Image

Gaussian Filtered Image

Gaussian Filtered Image

Lines - Gaussian Filtered Image

Guided Filtered Image

Guided Filtered Image

Lines - 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).

  • $\begingroup$ Thank you for your reply. Would you add the matlab code for better visualization. $\endgroup$
    – Jame
    Feb 26, 2016 at 12:44
  • $\begingroup$ I added MATLAB Code and visualization. Enjoy... $\endgroup$
    – Royi
    Feb 26, 2016 at 16:35
  • $\begingroup$ 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? $\endgroup$
    – Jame
    Feb 26, 2016 at 17:08
  • $\begingroup$ 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). $\endgroup$
    – Royi
    Feb 27, 2016 at 13:14
  • $\begingroup$ Thank you. If I consider Gaussian noise with (zero mean, and variance v), then lower frequency noise means low variance v. Is it right? $\endgroup$
    – Jame
    Apr 2, 2016 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.