Read an Image with python

  • If you want to read an image, you will need the ‘image’ package:
    • import Image
  • read the image:
    • Image.open(filename)
  • convert the Image to grey scale:
    • Image.open(filename).convert('L')
  • convert the image to array:
    • numpy.asarray(Image.open(filename).convert('L'))

Notice:

  • Here is a introduction to “Image” package
  • opencv, pillow are the python image library

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.