imread_examples.py 809 B

12345678910111213141516171819202122
  1. #!/usr/bin/python
  2. import cv2
  3. # Read 8-bit grayscale image
  4. im = cv2.imread("earth-16-bit-per-channel.png", cv2.IMREAD_GRAYSCALE)
  5. print "flags : cv2.IMREAD_GRAYSCALE"
  6. print "Size %s, type %s\n" % (im.shape,im.dtype)
  7. # Read 8-bit color image
  8. im = cv2.imread("earth-16-bit-per-channel.png", cv2.IMREAD_COLOR)
  9. print "flags : cv2.IMREAD_COLOR"
  10. print "Size %s, type %s\n" % (im.shape,im.dtype)
  11. # Read 16-bit color image
  12. im = cv2.imread("earth-16-bit-per-channel.png", cv2.IMREAD_ANYCOLOR | cv2.IMREAD_ANYDEPTH )
  13. print "flags : cv2.IMREAD_ANYCOLOR | cv2.IMREAD_ANYDEPTH"
  14. print "Size %s, type %s\n" % (im.shape,im.dtype)
  15. # Read transparent PNG / TIFF image
  16. im = cv2.imread("earth-16-bit-per-channel.png", cv2.IMREAD_UNCHANGED)
  17. print "flags : cv2.IMREAD_UNCHANGED"
  18. print "Size %s, type %s\n" % (im.shape,im.dtype)