szymcio10

Przykłady

May 18th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.28 KB | None | 0 0
  1. close all;
  2. clear all;
  3.  
  4. IMG_1 = imread('calculator.png');
  5.  
  6. SE = ones(1,71);
  7. erode = imerode(IMG_1,SE);
  8. obr = imreconstruct(erode,IMG_1);
  9. obr_1 = imopen(IMG_1,SE);
  10. tep = IMG_1-obr;
  11. topIMG_1 = imtophat(IMG_1,SE);
  12.  
  13. figure(1)
  14. subplot(3,3,1)
  15. imshow(IMG_1)
  16. title('Obraz originalny')
  17. subplot(3,3,2)
  18. imshow(obr)
  19. title('Obraz po operacji otwarcia przez rekonstrucje')
  20. subplot(3,3,3)
  21. imshow(obr_1)
  22. title('Obraz po operacji otwarcia przez rekonstrucje')
  23. subplot(3,3,4)
  24. imshow(tep)
  25. title('Obraz po operacji odejmowania')
  26. subplot(3,3,5)
  27. imshow(topIMG_1)
  28. title('Obraz po operacji top-hat')
  29.  
  30. %-----------------------------------------------------
  31.  
  32. SE_1 = ones(1,11);
  33. erode_1 = imerode(IMG_1,SE_1);
  34. obr_1 = imreconstruct(erode_1,IMG_1);
  35.  
  36. subplot(3,3,6)
  37. imshow(obr_1)
  38. title('Obraz po operacji rekonstrukcji(ones 1,11)+erozji')
  39.  
  40. %-------------------------------------------------------
  41.  
  42. SE_2 = ones(1,21);
  43. erode_2 = imdilate(IMG_1,SE_2);
  44. obr_2 = imreconstruct(erode_2,topIMG_1);
  45. obr_3 = imreconstruct(erode_2,imdilate(IMG_1,SE_1));
  46.  
  47. subplot(3,3,7)
  48. imshow(obr_2)
  49. title('Obraz po operacji rekonstrukcji')
  50. subplot(3,3,8)
  51. imshow(obr_3)
  52. title('Obraz po operacji rekonstrukcji')
  53.  
  54.  
  55. %Tak udało się otrzymać zamierzony efekt, widać to na wykresie "Obraz po
  56. %odejmowaniu"
Advertisement
Add Comment
Please, Sign In to add comment