Advertisement
pabloducato

pompa

Oct 22nd, 2018
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.94 KB | None | 0 0
  1. vid = videoinput('winvideo');
  2. %preview(vid)
  3. obraz = getsnapshot(vid);
  4. figure(2);
  5. imshow(obraz)
  6. title('Obraz kolorowy');
  7. %musimy ustawić właściwiośc trigger repeat
  8. set(vid, 'TriggerRepeat', Inf);
  9. %start(vid);
  10. %na bieżąco trzeba pobierać
  11. %while vid.FramesAcquired < 1000, %dopóki nie przetworzymy 300 klatek
  12. while true,
  13. %obraz = getdata(vid, 1);
  14. %flushdata(vid); %getdata pobiera obraz i czyści bufor
  15. obraz = getsnapshot(vid);
  16. obraz_sz = rgb2gray (obraz);
  17. figure(2);
  18. subplot(2,2,1);
  19. imshow(obraz);
  20. title('kolorowy');
  21. subplot(2,2,2);
  22. imshow(obraz_sz);
  23. title('szary');
  24. subplot(2,2,3);
  25. imhist (obraz_sz);
  26. obraz_wh = histeq (obraz_sz);
  27. imshow (obraz_wh);
  28. prog_bin = graythresh (obraz_sz);
  29. subplot(2,2,4);
  30. obraz_czb = im2bw (obraz_sz, prog_bin); %[0,1]
  31. imshow (obraz_czb);
  32. title('czarno-bialy');
  33. %vid.FramesAvailable
  34. %flushdata(vid);
  35. %pause(0.1);     <- czas w milisekundach
  36. end
  37. %stop(vid);
  38. delete vid;
  39. close(gcf);
  40. clear;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement