Reputation: 11
I'm trying to get the code to give me an output of the rgb value of a certain pixel
Input:
from PIL import Image
img=Image.open(r"C:\img1.png")
pixelMap = img.load()
pixel = pixelMap[0,0]
print(pixel)
Output:0
Desired Output: (0, 0, 0)
Upvotes: 1
Views: 46
Reputation: 207445
Your image is probably a palette image - see here. So change your code to this:
from PIL import Image
# Load image - ensuring RGB not palette
img=Image.open(r"C:\img1.png").convert('RGB')
pixelMap = img.load()
pixel = pixelMap[0,0]
print(pixel)
Upvotes: 1