Created
September 17, 2012 05:50
-
-
Save Ripley6811/3735758 to your computer and use it in GitHub Desktop.
PIL image to CV2 image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PIL RGB 'im' to CV2 BGR 'imcv' | |
imcv = np.asarray(im)[:,:,::-1].copy() | |
# Or | |
imcv = cv2.cvtColor(np.asarray(im), cv2.COLOR_RGB2BGR) | |
# To gray image | |
imcv = np.asarray(im.convert('L')) | |
# Or | |
imcv = cv2.cvtColor(np.asarray(im), cv2.COLOR_RGB2GRAY) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment