Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import cv2
- # "path"には画像のパスを入力
- img = cv2.imread("path")
- # BGRの順で記録されている点に注意
- b = img[:, :, 0].copy()
- g = img[:, :, 1].copy()
- r = img[:, :, 2].copy()
- # B <-> R
- img[:, :, 0] = r
- img[:, :, 2] = b
- cv2.imshow("image", img)
- cv2.waitKey(0)
- cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement