Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I load a multi-frame TIFF through OpenCV?

Anyone know if OpenCV is capable of loading a multi-frame TIFF stack? I'm using OpenCV 2.2.0 with python 2.6.

like image 218
so12311 Avatar asked Sep 07 '11 14:09

so12311


People also ask

Does OpenCV support TIFF files?

So, OpenCV can always read JPEGs, PNGs, and TIFFs.

Can a TIFF file have multiple pages?

The drawings are mostly single page tiff images, but the documents may have multiple pages. For an interim fix to the issue, you will have to download a tiff viewer from the app store.


2 Answers

OpenCV is now capable of reading a multi-page TIFF using the imreadmulti function. See this page from the OpenCV 3.4 documentation:

https://docs.opencv.org/3.4/d4/da8/group__imgcodecs.html#ga4dd47c9ae3d55cc42286cff005825e31

like image 50
John Walthour Avatar answered Sep 21 '22 00:09

John Walthour


You can load multi-frame tiff files in OpenCV using file read function called imreadmulti. Here is the example

 ret, images = cv2.imreadmulti('<path_of_tiff_files>.tiff', [], cv2.IMREAD_ANYCOLOR)

Images will be a list of frames in the tiff file. Suppose you want to see 2nd image, you can access as

img = images[1] # note 0 based indexing
like image 39
sam Avatar answered Sep 19 '22 00:09

sam