SHARE
TWEET

Untitled

a guest Jun 19th, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. O = double(imread('kierowca.png'));
  2. colormap(gray(256));
  3. Y = 0.2126.*O(:,:,1) + 0.7152.*O(:,:,2) + 0.0722.*O(:,:,3);
  4. subplot(4,4,1);
  5. colormap(gray(256));
  6. image(Y);
  7. title('obraz oryginalny');
  8.  
  9. subplot(4,4,2);
  10. X1 = Y./255;
  11. X1 = fft2(X1);
  12. image(fftshift(abs(X1)));
  13. title('');
  14.  
  15. subplot(4,4,3);
  16. Y2 = (X1 / max(max(X1))).*255;
  17. image(fftshift(abs(Y2)));
  18. title('');
  19.  
  20. subplot(4,4,4);
  21. Y3 = X1;
  22. Y3 = ifft2(Y3);
  23. image(real(Y3).*255);
  24. title('');
  25.  
  26. %etap2
  27. subplot(4,4,5);
  28. X1(1,1) = X1(1,1)*2;
  29. X1 = ifft2(X1);
  30. [J K] = fJasKon(X1);
  31. image(X1.*255);
  32.  
  33. %etap3
  34. P = double(imread('litery.png'));
  35. colormap(gray(256));
  36. X = 0.2126.*P(:,:,1) + 0.7152.*P(:,:,2) + 0.0722.*P(:,:,3);
  37. subplot(4,4,6);
  38. colormap(gray(256));
  39. image(X);
  40. title('obraz oryginalny');
  41.  
  42. %maska obraz
  43. X3 = X./255;
  44. [m n] = size(X3);
  45. X3 = zeros(m,n);
  46.  
  47. mmask11 = zeros(m,n);
  48. mmask11(ms, me) = 1;
  49. mmask11(ns, ne) = 1;
  50.  
  51. mmask12 = fliplr(mmask11);
  52. mmask21 = flipud(mmask11);
  53. mmask22 = fliplr(mmask21);
  54.  
  55. ms = m - 4 : m;
  56. me = 1 : m;
  57. ns = n - 4 : n;
  58. ne = 1 : n;
  59.  
  60. mmask = [mmask11 mmask12; mmask21 mmask22];
  61. subplot(4,4,7);
  62. image(mmask.*255);
  63. title('maska obraz');
  64.  
  65. %maska widmo
  66. X1 = X./255;
  67. X1 = fft2(X1);
  68.  
  69. [w k] = size(X1);
  70.  
  71. X2 = zeros(w,k);
  72.  
  73. mask11 = zeros(w,k);
  74.  
  75. mask11(ws, ke) = 1;
  76. mask11(we, ks) = 1;
  77.  
  78. mask12 = fliplr(mask11);
  79. mask21 = flipud(mask11);
  80. mask22 = fliplr(mask21);
  81.  
  82. ws = w - 4 : w;
  83. we = 1 : w;
  84. ks = k - 4 : k;
  85. ke = 1 : k;
  86. mask = [mask11 mask12; mask21 mask22];
  87. subplot(4,4,8);
  88. image(mask.*255);
  89. title('maska widmo');
RAW Paste Data
Top