Skip to content

Instantly share code, notes, and snippets.

@vsanse
Last active August 13, 2017 13:23
Show Gist options
  • Save vsanse/ac69f5d95ffbe7e878fe74ec0a811da3 to your computer and use it in GitHub Desktop.
Save vsanse/ac69f5d95ffbe7e878fe74ec0a811da3 to your computer and use it in GitHub Desktop.
import cv2
# loading as default colored image
img1 = cv2.imread('watch.jpg')
# loading image as grayscale image
img2 = cv2.imread('watch.jpg', cv2.IMREAD_GRAYSCALE)
#IMREAD_COLOR=1,IMREAD_UNCHANGED=-1,IMREAD_GRAYSCALE=0
#loading unchanged image
img3 = cv2.imread('watch.jpg', cv2.IMREAD_UNCHANGED)
# showing images
cv2.imshow('COLORED_IMAGE', img1)
cv2.imshow('GRAYSCALE_IMAGE', img2)
cv2.imshow('UNCHANGED_IMAGE', img3)
# output window wait infinitely for a key press
cv2.waitKey(0)
# closes all output windows on keypress
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment