Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. %% 1
  2. clc
  3. clear all
  4. close all
  5.  
  6. A=zeros(128,128);
  7. A(3:4:128,:)=1;
  8. A(4:4:128,:)=1;
  9. F=fftshift(fft2(A));
  10. subplot(2,1,1)
  11. imshow(A)
  12. title('oryginal')
  13. subplot(2,1,2)
  14. imshow(log(1+abs(F)));
  15. title ('w. amplitudowe')
  16.  
  17. %% 2
  18. clc
  19. clear all
  20. close all
  21.  
  22. A=zeros(32,32);
  23. A(13:18,6:26)=1;
  24. F=fftshift(fft2(A));
  25. F2=fftshift(fft2(A,256,256));
  26. subplot(3,1,1)
  27. imshow(A)
  28. title('oryg.')
  29. subplot(3,1,2)
  30. imshow(log(1+abs(F)));
  31. title ('transformata')
  32. subplot(3,1,3)
  33. imshow(log(1+abs(F2)));
  34. title('transformata 2')
  35.  
  36. %% 3
  37. clc
  38. clear all
  39. close all
  40.  
  41. I=imread('Clown.tif');
  42. I2=double(I)/255;
  43. F=fftshift(fft2(I2));
  44. figure(1)
  45. subplot(3,1,1)
  46. imshow(I)
  47. title('oryginał')
  48. subplot(3,1,2)
  49. imshow(log10(1+abs(F)))
  50. title ('w. amp. log10')
  51. subplot(3,1,3)
  52. imshow(angle(F))
  53. title('w.fazowe')
  54.  
  55.  
  56. %% 4
  57. clc
  58. clear all
  59. close all
  60.  
  61. I=imread('Road.tif');
  62. I2=double(I)/255;
  63. F=fftshift(fft2(I2));
  64. I3=ifft2(ifftshift(F));
  65. I4=imsubtract(I3,I2);
  66. figure(1)
  67. subplot(2,1,1)
  68. imshow(log(1+abs(F)))
  69. title('w.amplitudowe')
  70. subplot(212)
  71. imshow(abs(F).^2)
  72. title ('w.mocy')
  73. figure(2)
  74. subplot(3,1,1)
  75. imshow(I2)
  76. title('oryginalny')
  77. subplot(3,1,2)
  78. imshow(I3)
  79. title('odtworzony')
  80. subplot (3,1,3)
  81. imshow(I4)
  82. title('roznica')
  83.  
  84. %% 5
  85. clc
  86. clear all
  87. close all
  88.  
  89. org=imread('Road.tif');
  90. orgd = double(org)/255;
  91.  
  92. ftorg=fftshift(fft2(orgd));
  93. fi1=ftorg;
  94. fi2=ftorg;
  95. a=60;
  96. b=150;
  97. %filtr gornooprzepustowy
  98. fi1(195-a/2:192+a/2,195-a/2:192+a/2)=0;
  99. fi1(175:215,175:215)=0;
  100. ft1=ifft2(ifftshift(fi1));
  101. %filtr dolnooprzepustowy
  102. fi2([1:b,(390-b):390],:)=0;
  103. fi2(:,[1:b,(390-b):390])=0;
  104. ft2=ifft2(ifftshift(fi2));
  105.  
  106.  
  107. figure(1)
  108. subplot(231)
  109. imshow(org)
  110. title('oryginal')
  111.  
  112. subplot(234)
  113. imshow(log(1+abs(ftorg)));
  114. title('widmo amplitudowe normalne ');
  115.  
  116. subplot(232)
  117. imshow(ft1);
  118. title('gorno');
  119.  
  120. subplot(233)
  121. imshow(ft2);
  122. title('dolno');
  123.  
  124. subplot(235)
  125. imshow(log(1+abs(fi1)));
  126. title('filtr gorno');
  127.  
  128. subplot(236)
  129. imshow(log(1+abs(fi2)));
  130. title('filtr dolno');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement