Advertisement
sowamaciej

Untitled

Oct 11th, 2020
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. img = plt.imread('photo2.jpg')
  5. R = img[:, :, 0]
  6. G = img[:, :, 1]
  7. B = img[:, :, 2]
  8. fig = plt.figure(figsize=(10, 10))
  9. columns = 4
  10. rows = 4
  11.  
  12. fig.add_subplot(rows, columns, 1)
  13. plt.title("O")
  14. plt.imshow(img)
  15. fig.add_subplot(rows, columns, 2)
  16. plt.title("R")
  17. plt.imshow(R)
  18. fig.add_subplot(rows, columns, 3)
  19. plt.title("G")
  20. plt.imshow(G)
  21. fig.add_subplot(rows, columns, 4)
  22. plt.title("B")
  23. plt.imshow(B)
  24.  
  25. fig.add_subplot(rows, columns, 6)
  26. plt.imshow(R, cmap=plt.cm.gray, vmin=0, vmax=255)
  27. fig.add_subplot(rows, columns, 7)
  28. Y = 0.2126 * R + 0.7152 * G + 0.0722 * B
  29. plt.imshow(Y, cmap=plt.cm.gray, vmin=0, vmax=255)
  30.  
  31. plt.show()
  32.  
  33.  
  34.  
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement