Skip to content

Instantly share code, notes, and snippets.

@Yuktha-Majella
Created October 26, 2021 14:32
Show Gist options
  • Save Yuktha-Majella/2ba76d0d8550b51ab1014fad427e026f to your computer and use it in GitHub Desktop.
Save Yuktha-Majella/2ba76d0d8550b51ab1014fad427e026f to your computer and use it in GitHub Desktop.
#Accessing BGR value of pixel in coordinates 100,100
pixel = img[100,100]
print("Pixel value in (100,100) coordinate: ", pixel)
#Accessing blue, Red, Green pixel individually
blue = img[100,100,0]
green = img[100,100,1]
red = img[100,100,2]
print("Pixel value of Blue in (100,100) coordinate: ", blue)
print("Pixel value of Green in (100,100) coordinate: ", green)
print("Pixel value of Red in (100,100) coordinate: ", red)
#Accessing a group of pixels: first 2 rows and first 2 columns
pixel = img[:2, :2]
print("Pixel value in (100,100) coordinate: \n", pixel)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment