load and display image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sarfarazfarru
    New Member
    • May 2010
    • 12

    #1

    load and display image

    i am very new to python at learning stage.
    i had downloaded the pil .
    where i should save the image file.
    how i can open the file.
    it showing that file is not found.
    also i want know the pixel value.
    please help me regarding how to use the pil
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    You can save your image file wherever you want. All you need is the path. Here's an example that prints each RGB tuple that falls with a defined upper and lower limit:
    Code:
    from PIL import Image
    import operator
    
    img = Image.open(r'D:\Miscellaneous\image.png')
    
    # Count the pixels having RGB values in defined range
    
    upper = (256,40,40)
    lower = (190,0,0)
    
    print '\n'.join([str(pixel) for pixel in img.getdata() \
                     if False not in map(operator.lt,lower,pixel) \
                     and False not in map(operator.gt,upper,pixel)])

    Comment

    Working...