Skip to content

Instantly share code, notes, and snippets.

@doron2402
Last active September 29, 2020 23:40
Show Gist options
  • Save doron2402/fcb5ae1fd47023347da2908043b22cff to your computer and use it in GitHub Desktop.
Save doron2402/fcb5ae1fd47023347da2908043b22cff to your computer and use it in GitHub Desktop.
OpenCV2 read image and show different colors
import numpy as np
import cv2
img = cv2.imread('./<LINK TO YOUR IMAGE>')
# [x, y, color]
# colors are [blue, green, red]
blue = img[:,:,0]
green = img[:,:,1]
red = img[:,:,2]
# Show image
cv2.imshow('Image', img)
cv2.imshow('Blue Colors', blue)
cv2.imshow('Green Colors', green)
cv2.imshow('Red Colors', red)
cv2.waitKey(0)
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment