szymcio10

Operacje morfologiczne dla obrazów w skali szarości

May 17th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.09 KB | None | 0 0
  1. close all;
  2. clear all;
  3.  
  4. IMG_1 = imread('ferrari.bmp');
  5. SE = strel('square',3);
  6.  
  7. erIMG_1 = imerode(IMG_1,SE);
  8. dyIMG_1 = imdilate(IMG_1,SE);
  9. opIMG_1 = imopen(IMG_1,SE);
  10. clIMG_1 = imclose(IMG_1,SE);
  11. topIMG_1 = imtophat(IMG_1,SE);
  12. botIMG_1 = imbothat(IMG_1,SE);
  13.  
  14. figure(1)
  15. subplot(3,3,1)
  16. imshow(IMG_1)
  17. title('Obraz originalny')
  18. subplot(3,3,2)
  19. imshow(erIMG_1)
  20. title('Obraz po erozji')
  21. subplot(3,3,3)
  22. imshow(dyIMG_1)
  23. title('Obraz po dylatacji')
  24. subplot(3,3,4)
  25. imshow(opIMG_1)
  26. title('Obraz po otwarciu')
  27. subplot(3,3,5)
  28. imshow(clIMG_1)
  29. title('Obraz po zamknieciu')
  30. subplot(3,3,6)
  31. imshow(topIMG_1)
  32. title('Obraz po top-hat')
  33. subplot(3,3,7)
  34. imshow(botIMG_1)
  35. title('Obraz po bot-hat')
  36.  
  37. %udało sie odkryć zarys(kontury) samochodu
  38.  
  39. IMG_2 = imread('rice.png');
  40. SE_2 = strel('disk',10);
  41.  
  42. topIMG_2 = imtophat(IMG_2,SE);
  43.  
  44. figure(2)
  45. subplot(1,2,1)
  46. imshow(IMG_2)
  47. title('Obraz originalny')
  48. subplot(1,2,2)
  49. imshow(topIMG_2)
  50. title('Obraz po operacji top-hat')
  51.  
  52. %zniszczyło obraz, jest cały ciemny, widać tylko pojedyncze kropki, można
  53. %zakladać że nie ma już oświetlenia
Advertisement
Add Comment
Please, Sign In to add comment