0

Hi I'm trying to use PIL to get data from an image and find 'unusual' RBG values but haven't found the right way.

Import Image, PIL

im=Image.open("image.bmp")
ans=im.getdata()
print ans

This doesn't examine the RGB values for me to find any unusual ones. If tried others like:
im.load()
im.getpixels()
im.getbands()
but haven't found the right one yet.

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by kiddo39
Featured Replies
  • 1

    Here is an example ... [code=python]# show the list of (r, g, b) tuples of a bitmap image from PIL import Image img = Image.open("FrenchFlag.bmp") data = img.getdata() #show a list of (r, g, b) tuples print(list(data)) """ partial output --> [(6, 0, 240), (6, 0, 240), (6, 0, 240), … Read More

1

Here is an example ...

# show the list of (r, g, b) tuples of a bitmap image

from PIL import Image

img = Image.open("FrenchFlag.bmp")
data = img.getdata()

#show a list of (r, g, b) tuples
print(list(data))

"""
partial output -->
[(6, 0, 240), (6, 0, 240), (6, 0, 240), (6, 0, 240),
(6, 0, 240), (6, 0, 240), (6, 0, 240), (85, 81, 244),
(253, 252, 255), (255, 255, 255),(255, 255, 255), (255, 255, 255),
(255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255),
(255, 255, 255), (255, 251, 251), (244, 71, 67), (240, 6, 0),
(240, 6, 0), (240, 6, 0), (240, 6, 0), (240, 6, 0), (240, 6, 0), (
240, 6, 0), (6, 0, 240), ...]
"""

Now you can search/process the list for any unusual (r, g, b) tuple.

Comments
Always very helpful
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.