Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. import matplotlib.image as mpimg
  4.  
  5.  
  6.  
  7. def rgb2gray(rgb):
  8. return np.dot(rgb[...,:3], [0.299, 0.587, 0.114])
  9.  
  10. img = mpimg.imread('Hamburger_sandwich.jpg')
  11. gray = rgb2gray(img)
  12. plt.imshow(gray, cmap = plt.get_cmap('gray'))
  13.  
  14.  
  15. #imgplot = plt.imshow(img)
  16. #lum_img = img[:,:,0]
  17. #plt.imshow(lum_img)
  18. #plt.imshow(lum_img, cmap="hot")
  19. #imgplot = plt.imshow(lum_img)
  20. #imgplot.set_cmap('nipy_spectral')
  21. #imgplot = plt.imshow(lum_img)
  22. #plt.colorbar()
  23. #plt.hist(img.ravel(), bins=256, range=(0.0, 1.0), fc='k', ec='k')
  24. #imgplot = plt.imshow(lum_img, clim=(0.0, 0.7))
  25. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement