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.

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.

commented: Always very helpful +1

Ok, thank you. That will work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.