Home > Back-end >  How open a stack of .tif images with python
How open a stack of .tif images with python

Time:01-25

i have a file with 300 .tif images, i want to open it with python and save them into an array, list or any similar structure. I´ve tried the code below but only appears 3 images. ¿Any solution?. Thanks.

raw = cv2.imread('sen_15Hz_500Hz_6_6A.tif')
print(np.shape(raw))

enter image description here

I´ve tried with PIL and cv2 too.

CodePudding user response:

If you really have one single TIFF file with 300 images in it, the simplest is to open it with tifffile.

with TiffFile('temp.tif') as tif:
   for page in tif.pages:
      image = page.asarray()

If you want to use PIL look at the section "Image Sequences" here.

  • Related