Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. close all;
  2. clearvars;
  3. clc;
  4.  
  5. obraz = imread('lena.bmp');
  6.  
  7. Fobraz = fft2(obraz);
  8. przesuniecie = fftshift(Fobraz);
  9.  
  10. A = log10(abs(Fobraz)+1);
  11. F = angle(Fobraz.*(A>0.0001));
  12.  
  13. figure;
  14. subplot(1,3,1)
  15. imshow(obraz);
  16. subplot(1,3,2);
  17. imshow(A, []);
  18. subplot(1,3,3);
  19. imshow(F, []);
  20.  
  21. [f1, f2] = freqspace(512, 'meshgrid');
  22. Hd = ones(512);
  23. r = sqrt(f1.^2 + f2.^2);
  24. Hd((r>0.1)) = 0;
  25.  
  26. przefiltrowane = przesuniecie.*Hd;
  27. i1 = ifftshift(przefiltrowane);
  28. i2 = ifft2(i1);
  29.  
  30. figure;
  31. subplot(1,3,1);
  32. imshow(obraz);
  33. subplot(1,3,2);
  34. imshow(uint8(i2), []);
  35. subplot(1,3,3);
  36. imshow(imsubtract(obraz,uint8(i2)),[]);
  37.  
  38.  
  39. [f1, f2] = freqspace(512, 'meshgrid');
  40. Hd = ones(512);
  41. r = sqrt(f1.^2 + f2.^2);
  42. Hd((r<0.1)) = 0;
  43.  
  44. przefiltrowane = przesuniecie.*Hd;
  45. i1 = ifftshift(przefiltrowane);
  46. i2 = ifft2(i1);
  47.  
  48. figure;
  49. subplot(1,3,1);
  50. imshow(obraz);
  51. subplot(1,3,2);
  52. imshow(uint8(i2), []);
  53. subplot(1,3,3);
  54. imshow(imsubtract(obraz,uint8(i2)),[]);
  55.  
  56. [f1, f2] = freqspace(512, 'meshgrid');
  57. Hd = ones(512);
  58. r = sqrt(f1.^2 + f2.^2);
  59. Hd(((r>0.4)&(r<0.6))) = 0; % exp
  60.  
  61. przefiltrowane = przesuniecie.*Hd;
  62. i1 = ifftshift(przefiltrowane);
  63. i2 = ifft2(i1);
  64.  
  65. figure;
  66. subplot(1,3,1);
  67. imshow(obraz);
  68. subplot(1,3,2);
  69. imshow(uint8(i2), []);
  70. subplot(1,3,3);
  71. imshow(imsubtract(obraz,uint8(i2)),[]);
  72.  
  73. [f1, f2] = freqspace(512, 'meshgrid');
  74. Hd = ones(512);
  75. r = sqrt(f1.^2 + f2.^2);
  76. Hd((r>0.1)) = 0;
  77.  
  78. h = fwind1(Hd, hanning(21));
  79. [H, f1, f2] = freqz2(h, 512, 512);
  80.  
  81. przefiltrowane = przesuniecie.*H;
  82. i1 = ifftshift(przefiltrowane);
  83. i2 = ifft2(i1);
  84.  
  85. figure;
  86. subplot(1,3,1);
  87. imshow(obraz);
  88. subplot(1,3,2);
  89. imshow(uint8(i2), []);
  90. subplot(1,3,3);
  91. imshow(imsubtract(obraz,uint8(i2)),[]);
  92.  
  93. [f1, f2] = freqspace(512, 'meshgrid');
  94. Hd = ones(512);
  95. r = sqrt(f1.^2 + f2.^2);
  96. Hd((r<0.5)) = 0;
  97.  
  98. h = fwind1(Hd, hanning(21));
  99. [H, f1, f2] = freqz2(h, 512, 512);
  100.  
  101. przefiltrowane = przesuniecie.*H;
  102. i1 = ifftshift(przefiltrowane);
  103. i2 = ifft2(i1);
  104.  
  105.  
  106. figure;
  107. subplot(1,3,1);
  108. imshow(obraz);
  109. subplot(1,3,2);
  110. imshow(uint8(i2), []);
  111. subplot(1,3,3);
  112. imshow(imsubtract(obraz,uint8(i2)),[]);
  113.  
  114. figure;
  115. mesh(f1,f2,H);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement