Skip to content

Instantly share code, notes, and snippets.

@palaashatri
Last active August 12, 2020 06:01
Show Gist options
  • Save palaashatri/d655eb8f364a62ee50b6c251b4731396 to your computer and use it in GitHub Desktop.
Save palaashatri/d655eb8f364a62ee50b6c251b4731396 to your computer and use it in GitHub Desktop.
Demonstration of OpenCV Data Types and Data Structures from an image
import numpy as np
import cv2
black = np.zeros([150,200,1],'uint8')
cv2.imshow("Black",black)
print(black[0,0,:])
ones = np.ones([15,200,3],'uint8')
cv2.imshow("Ones",ones)
print(ones[0,0,:])
white = np.ones([150,200,3],'uint16')
white *= (2**16-1)
cv2.imshow("White",white)
print(white[0,0,:])
color = ones.copy()
color[:,:] = (255,0,0)
cv2.imshow("Blue",color)
print(color[0,0,:])
cv2.waitKey(0)
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment