following this link i was able to load and read pixels from a .gif. That question specifically askes for a RGB value, but the accepted (and most voted answer) that I used as reference gets me to get an int as value. What is it? I guess some sort of index, but how to convert it to a proper rgb value? Thanks
[..]
img = Image.open(GIF_FILENAME)
pix = img.load()
for i in range(5):
print img.getpixel((i, 0))
# this returns me like 78, 65.. how to get RGB?
[..]
The basic difference between OpenCV image and PIL image is OpenCV follows BGR color convention and PIL follows RGB color convention and the method of converting will be based on this difference.
getpixel(self, xy): Returns the pixel at x,y. The pixel is returned as a single. value for single band images or a tuple for multiple band images. param xy: The pixel coordinate, given as (x, y).
img = Image.open(GIF_FILENAME)
rgbimg = img.convert('RGB')
for i in range(5):
print rgbimg.getpixel((i, 0))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With