StevanovicMilan

10.6

Sep 18th, 2021
796
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '''
  2. Sa slike elementi.bmp izdvojiti plave elemente koristeći HSV domen.
  3. '''
  4.  
  5. import plotly.express as px
  6. from skimage import io
  7. import numpy as np
  8.  
  9. img = io.imread('elementi.bmp')
  10. fig = px.imshow(img)
  11. fig.show()
  12.  
  13. from skimage import color
  14.  
  15. img_hsv = color.rgb2hsv(img)
  16. fig = px.imshow(img_hsv[:,:,0], color_continuous_scale='gray')
  17. fig.show()
  18.  
  19. mb = (0.55 < img_hsv[:,:,0]) & (img_hsv[:,:,0] < 0.65)
  20. fig = px.imshow(mb, color_continuous_scale='gray')
  21. fig.show()
  22.  
  23. fig = px.imshow(img_hsv[:,:,1], color_continuous_scale='gray')
  24. fig.show()
  25.  
  26. ms = img_hsv[:,:,1] > 0.35
  27. fig = px.imshow(ms, color_continuous_scale='gray')
  28. fig.show()
  29.  
  30. m = mb & ms
  31. fig = px.imshow(m, color_continuous_scale='gray')
  32. fig.show()
  33.  
  34. img_masked = img * np.stack((m,m,m),axis=2)
  35. fig = px.imshow(img_masked)
  36. fig.show()
RAW Paste Data