Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. import numpy as np
  2. import cv2
  3.  
  4. # "path"には画像のパスを入力
  5. img = cv2.imread("path")
  6.  
  7. # BGRの順で記録されている点に注意
  8. b = img[:, :, 0].copy()
  9. g = img[:, :, 1].copy()
  10. r = img[:, :, 2].copy()
  11.  
  12. # B <-> R
  13. img[:, :, 0] = r
  14. img[:, :, 2] = b
  15.  
  16. cv2.imshow("image", img)
  17. cv2.waitKey(0)
  18. cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement