Facebook
From Flying Pudu, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 195
  1. clear all
  2. clc
  3.  
  4. imaqhwinfo
  5. vid = videoinput('winvideo')
  6. obraz=getsnapshot(vid);
  7. obr_sz=rgb2gray(obraz);
  8.  
  9. obraz=imresize(obr_sz , 0.25);
  10.  
  11. %tworzenie obrazow z zakloceniami
  12.  
  13. obr_g=imnoise(obraz, 'gaussian');
  14. obr_sp=imnoise(obraz, 'salt & pepper');
  15. obr_p=pasy(obraz, 1, 25, 'poziome');
  16. figure(1);
  17. subplot(4,3,1); imshow(obr_g);  title('gaus');
  18. subplot(4,3,2); imshow(obr_sp);  title('salt and pepper');
  19. subplot(4,3,3); imshow(obr_p);  title('poziome');
  20.  
  21. %FILTRY
  22. %usredniajacy
  23. h_usr3=fspecial('average', [7 7]);
  24. obr_f = imfilter(obr_g,h_usr3);
  25. subplot(4,3,4); imshow(obr_f); title('usredniajacy');
  26.  
  27. h_usr3=fspecial('average', [7 7]);
  28. obr_f = imfilter(obr_sp,h_usr3);
  29. subplot(4,3,5); imshow(obr_f); title('usredniajacy');
  30.  
  31. h_usr3=fspecial('average', [7 7]);
  32. obr_f = imfilter(obr_p,h_usr3);
  33. subplot(4,3,6); imshow(obr_f); title('usredniajacy');
  34.  
  35.  
  36.  
  37. %gaussa
  38. h_gauss = fspecial('gaussian', [3 7]);
  39. obr_f = imfilter(obr_g,h_gauss);
  40. subplot(4,3,7);
  41. imshow(obr_f);
  42. title('gauss');
  43.  
  44. h_gauss = fspecial('gaussian', [3 7]);
  45. obr_f = imfilter(obr_sp,h_gauss);
  46. subplot(4,3,8);
  47. imshow(obr_f);
  48. title('gauss');
  49.  
  50. h_gauss = fspecial('gaussian', [3 7]);
  51. obr_f = imfilter(obr_p,h_gauss);
  52. subplot(4,3,9);
  53. imshow(obr_f);
  54. title('gauss');
  55.  
  56.  
  57. %medianwy
  58. obr_f = medfilt2(obr_g, [3 7]);
  59. subplot(4,3,10);
  60. imshow(obr_f);
  61. title('medianwy');
  62.  
  63. obr_f = medfilt2(obr_sp, [3 7]);
  64. subplot(4,3,11);
  65. imshow(obr_f);
  66. title('medianwy');
  67.  
  68. obr_f = medfilt2(obr_p, [3 7]);
  69. subplot(4,3,12);
  70. imshow(obr_f);
  71. title('medianwy');
  72.  
  73. %operator Sobela
  74. figure(2)
  75. h_sob1=fspecial('sobel');
  76. kraw_sob1=filter2(h_sob1,obr_sz);
  77. subplot(2,2,1);
  78. imshow(kraw_sob1);
  79. title('sobel1')
  80.  
  81. h_sob2=-h_sob1';
  82. kraw_sob2=filter2(h_sob2,obr_sz);
  83. subplot(2,2,2);
  84. imshow(kraw_sob2);
  85. title('sobel2')
  86.  
  87. %operator laplacea
  88. h_lap=fspecial('LAPLACIAN');
  89. kraw_lap=filter2(h_lap,obr_sz);
  90. subplot(2,2,3);
  91. imshow(kraw_lap);
  92. title('laplace1')
  93.  
  94. %operator laplacea
  95.  
  96. h_log=fspecial('log');
  97. kraw_log=filter2(h_log,obr_sz);
  98. subplot(2,2,4);
  99. imshow(kraw_log);
  100. title('logarytmiczny')
  101.  
  102.  
  103.  
  104. h_sob2=-h_sob1';
  105. kraw_sob2=filter2(h_sob2,obr_sz);
  106. figure(3);
  107. subplot(111)
  108. imshow(kraw_sob2);
  109.