SHARE
TWEET

Gaussian Filter

a guest Sep 15th, 2019 124 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. X = [
  2.     -1,0,1;
  3.     -1,0,1;
  4.     -1,0,1
  5.     ];
  6.  
  7. Y = [
  8.     -1,-1,-1;
  9.     0,0,0;
  10.     1,1,1;
  11.     ];
  12.  
  13. si = 0.9;
  14. gaus = (1 / (2 * 3.1416 * si^2)) * exp(-(X.^2 + Y.^2) / (2*si^2));
  15.  
  16.  
  17. I = imread('coins.png');
  18. I2 = imnoise(I,'gaussian', 0.02);
  19. I3 = I2;
  20. [row, col] = size(I2);
  21. temp = zeros(3,3);
  22.  
  23. for i = 1:row-2
  24.     for j = 1:col-2        
  25.         N = I2(i:i+2, j:j+2);
  26.        
  27.            for x = 1:3
  28.                for y = 1:3
  29.                     temp(x,y) = gaus(x,y) * N(x,y);
  30.                 end
  31.            end                      
  32.         t = sum(temp(:));
  33.         I3(i+1, j+1) = t;                                          
  34.     end
  35. end
  36.  
  37. imshow(I3);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top