Advertisement
sildren12

LAB 3.1

Nov 10th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.92 KB | None | 0 0
  1. info=imaqhwinfo
  2. vid=videoinput('winvideo')
  3. %preview(vid)
  4. get(vid)
  5. get(getselectedsource(vid))
  6. set(vid, 'TriggerRepeat', Inf)
  7. set(gcf, 'doublebuffer', 'on')
  8. start(vid)
  9. figure(1)
  10. while(vid.FramesAcquired <=10)
  11.     data=getsnapshot(vid);
  12.     obraz=rgb2gray(data);
  13.     subplot(2,2,1);
  14.     imshow(obraz);
  15. end
  16. %figure(2);
  17. subplot(2,2,2);
  18.  imhist(obraz);
  19.  %figure(3);
  20.  subplot(2,2,3);
  21.  histeq(obraz);
  22.  %level = graythresh(obraz);
  23.  %bin = im2bw(obraz,level);
  24.  %figure(4);
  25.  %subplot(2,2,4);
  26.  %imshow(bin);
  27.  
  28. %  figure(2);
  29. %  %zakolcenia gausa
  30. %  obr_g = imnoise(obraz,'gaussian');
  31. %  subplot(3,1,1);
  32. %  imshow(obr_g);
  33. %  
  34. %  hg=fspecial('gaussian',[3 3]);
  35. %  obr_h=imfilter(obr_g,hg);
  36. %  subplot(3,1,2)
  37. %  imshow(obr_h);
  38. %  hg1=fspecial('gaussian',[7 7]);
  39. %  obr_h1=imfilter(obr_g,hg1);
  40. %  subplot(3,1,3);
  41. %  imshow(obr_h1);
  42. %  
  43. %  figure(3);
  44. %  subplot(3,1,1);
  45. %  imshow(obr_g);
  46. %  h_usr=fspecial('average',[3 3])
  47. %  obr_f=imfilter(obr_g,h_usr);
  48. %  subplot(3,1,2);
  49. %  imshow(obr_f);
  50. %   h_usr1=fspecial('average',[7 7])
  51. %  obr_f1=imfilter(obr_g,h_usr1);
  52. %  subplot(3,1,3);
  53. %  imshow(obr_f1);
  54. %  
  55. %  figure(4);
  56. %  subplot(3,1,1);
  57. %  imshow(obr_g);
  58. %  obr_fm=medfilt2(obr_g, [3 3]);
  59. %  subplot(3,1,2);
  60. %  imshow(obr_fm);
  61. %  obr_fm1=medfilt2(obr_g, [7 7]);
  62. %  subplot(3,1,3);
  63. % %  imshow(obr_fm1);
  64. %
  65. %  figure(5);
  66. %  %zaklocenia sol i pieprz
  67. %  obr_sp=imnoise(obraz,'salt & pepper');
  68. %  subplot(3,1,1);
  69. %  imshow(obr_sp);
  70. %  
  71. %   hg=fspecial('gaussian',[3 3]);
  72. %  obr_h=imfilter(obr_sp,hg);
  73. %  subplot(3,1,2)
  74. %  imshow(obr_h);
  75. %  hg1=fspecial('gaussian',[7 7]);
  76. %  obr_h1=imfilter(obr_sp,hg1);
  77. %  subplot(3,1,3);
  78. %  imshow(obr_h1);
  79. %  
  80. %  figure(6);
  81. %  subplot(3,1,1);
  82. %  imshow(obr_sp);
  83. %  h_usr=fspecial('average',[3 3])
  84. %  obr_f=imfilter(obr_sp,h_usr);
  85. %  subplot(3,1,2);
  86. %  imshow(obr_f);
  87. %   h_usr1=fspecial('average',[7 7])
  88. %  obr_f1=imfilter(obr_sp,h_usr1);
  89. %  subplot(3,1,3);
  90. %  imshow(obr_f1);
  91. %  
  92. %  figure(7);
  93. %  subplot(3,1,1);
  94. %  imshow(obr_sp);
  95. %  obr_fm=medfilt2(obr_sp, [3 3]);
  96. %  subplot(3,1,2);
  97. %  imshow(obr_fm);
  98. %  obr_fm1=medfilt2(obr_sp, [7 7]);
  99. %  subplot(3,1,3);
  100. %  imshow(obr_fm1);
  101.  
  102. figure(8);
  103.  %zakloenia pasami
  104.  obr_p=pasy(obraz,1,50,'poziome');
  105.  subplot(3,1,1);
  106.  imshow(obr_p);
  107.  
  108.   hg=fspecial('gaussian',[3 3]);
  109.  obr_h=imfilter(obr_p,hg);
  110.  subplot(3,1,2)
  111.  imshow(obr_p);
  112.  hg1=fspecial('gaussian',[7 7]);
  113.  obr_h1=imfilter(obr_p,hg1);
  114.  subplot(3,1,3);
  115.  imshow(obr_h1);
  116.  
  117.  figure(9);
  118.  subplot(3,1,1);
  119.  imshow(obr_p);
  120.  h_usr=fspecial('average',[3 3])
  121.  obr_f=imfilter(obr_p,h_usr);
  122.  subplot(3,1,2);
  123.  imshow(obr_f);
  124.   h_usr1=fspecial('average',[7 7])
  125.  obr_f1=imfilter(obr_p,h_usr1);
  126.  subplot(3,1,3);
  127.  imshow(obr_f1);
  128.  
  129.  figure(10);
  130.  subplot(3,1,1);
  131.  imshow(obr_p);
  132.  obr_fm=medfilt2(obr_p, [3 3]);
  133.  subplot(3,1,2);
  134.  imshow(obr_fm);
  135.  obr_fm1=medfilt2(obr_p, [7 7]);
  136.  subplot(3,1,3);
  137.  imshow(obr_fm1);
  138. stop(vid)
  139. delete(vid)
  140. clear
  141.  
  142. close(gfc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement