Facebook
From Smelly Macaw, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 194
  1. Mask = [-1 -1 -1; -1 8 -1; -1 -1 -1];
  2.  
  3. lena = imread('lena.pgm');
  4.  
  5. lena2=conv2(lena,Mask);
  6.  
  7. figure(1);
  8. imshow(lena);
  9.  
  10. figure(2);
  11. imshow(uint8(lena2));
  12.  
  13.  
  14. F = fftshift(fft2(lena));
  15. M = log(abs(F)+1);
  16. M = (M./max(max(M)))*255;
  17. figure(3);
  18. imshow(uint8(M));
  19.  
  20.  
  21. F = fftshift(fft2(lena2));
  22. M = log(abs(F)+1);
  23. M = (M./max(max(M)))*255;
  24. figure(4);
  25. imshow(uint8(M));
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. Mask = [-1 0 1; -2 0 2; -1 0 1];
  37.  
  38. lena = imread('boats.pgm');
  39.  
  40. lena2=conv2(lena,Mask);
  41.  
  42. figure(1);
  43. imshow(lena);
  44.  
  45. figure(2);
  46. imshow(uint8(lena2));
  47.  
  48. F = fftshift(fft2(lena));
  49. M = log(abs(F)+1);
  50. M = (M./max(max(M)))*255;
  51. figure(3);
  52. imshow(uint8(M));
  53.  
  54.  
  55. F = fftshift(fft2(lena2));
  56. M = log(abs(F)+1);
  57. M = (M./max(max(M)))*255;
  58. figure(4);
  59. imshow(uint8(M));
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. mask5x5 = [1/25 1/25 1/25 1/25 1/25;
  70.         1/25 1/25 1/25 1/25 1/25;
  71.         1/25 1/25 1/25 1/25 1/25;
  72.         1/25 1/25 1/25 1/25 1/25;
  73.         1/25 1/25 1/25 1/25 1/25];
  74. mask7x7 = [1/49 1/49 1/49 1/49 1/49 1/49 1/49;
  75.             1/49 1/49 1/49 1/49 1/49 1/49 1/49;
  76.             1/49 1/49 1/49 1/49 1/49 1/49 1/49;
  77.             1/49 1/49 1/49 1/49 1/49 1/49 1/49;
  78.             1/49 1/49 1/49 1/49 1/49 1/49 1/49;
  79.             1/49 1/49 1/49 1/49 1/49 1/49 1/49;
  80.             1/49 1/49 1/49 1/49 1/49 1/49 1/49];
  81. mask9x9 = [1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81;
  82.     1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81;
  83.     1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81;
  84.     1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81;
  85.     1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81;
  86.     1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81;
  87.     1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81;
  88.     1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81;
  89.     1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81 1/81];
  90.  
  91. mask11x11 = [1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121;
  92.     1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121;
  93.     1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121;
  94.     1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121;
  95.     1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121;
  96.     1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121;
  97.     1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121;
  98.     1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121;
  99.     1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121;
  100.     1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121;
  101.     1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121 1/121];
  102.  
  103. lena = imread('lena.pgm');
  104.  
  105. lena2=conv2(lena,mask5x5);
  106. lena3=conv2(lena,mask7x7);
  107. lena4=conv2(lena,mask9x9);
  108. lena5=conv2(lena,mask11x11);
  109.  
  110. figure(1);
  111. imshow(lena);
  112.  
  113. figure(2);
  114. imshow(uint8(lena2));
  115.  
  116. figure(3);
  117. imshow(uint8(lena3));
  118. figure(4);
  119. imshow(uint8(lena4));
  120. figure(5);
  121. imshow(uint8(lena5));
  122.