Python reads TIFF multi-channel images

Source: Internet
Author: User

1.PIL
 from Import  = Image.open ("filename"

Support single channel and multi-channel Uint8 TIFF image reading, read single channel Uint16 TIFF image to Uint8 processing, direct read Uint16 TIFF multi-Channel image error, error message:

2.OpenCV
Import Cv2cv2.imread ("filename", Flags)

There are four options for Cv2,imread's flags on the number of channels and bit depths:

imread_unchanged = 1# does not convert, such as saving for 16 bits of the picture, read out is still 16 bits. Imread_grayscale = 0# is converted to grayscale, such as a picture saved for 16 bits, read out as 8 bits, and type CV_8UC1. Imread_color = 1# converted to RGB three-channel image, image depth to 8-bit imread_anydepth = 2# Keep image depth unchanged, convert to grayscale. Imread_anycolor = 4# If the number of image channels is less than or equal to 3, the number of original channels remains unchanged, and if the number of channels is greater than 3, only the first three channels are taken. Image depth converted to 8-bit

For multi-channel TIFF images, to ensure proper reading of image data, it is obvious to choose imread_unchanged as the Flags setting value for Imread.

* Not to Be continued

Python reads TIFF multi-channel images

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.