# Python - Read TIFF stacks with 3 and 4 pages

**URL:** https://discourse.itk.org/t/python-read-tiff-stacks-with-3-and-4-pages/1209
**Category:** Beginner Questions
**Tags:** python
**Created:** [August 17, 2018, 1:22pm UTC](https://discourse.itk.org/t/python-read-tiff-stacks-with-3-and-4-pages/1209 "2018-08-17T13:22:57Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![JayKay](https://discourse.itk.org/letter_avatar_proxy/v4/letter/j/54ee81/32.png) [@JayKay](https://discourse.itk.org/u/JayKay)
#### Post date: [August 17, 2018, 1:22pm UTC](https://discourse.itk.org/t/python-read-tiff-stacks-with-3-and-4-pages/1209/1 "2018-08-17T13:22:58Z")

</div>

Hi,

I’m trying to read tiff stacks with 3 or 4 images into itk with python like:

reader=itk.ImageFileReader.IF3.New(FileName=‘images.tif’)  
image=itk.Image.F3.New()  
reader.Update()  
image=readerA.GetOutput()

Apparently, the stacks are interpreted as single RGB-Image and the image size is [x,y,1]. How is it possible to get the stack with 3 or 4 pages?

Thank you very much in advance!

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [August 17, 2018, 1:31pm UTC](https://discourse.itk.org/t/python-read-tiff-stacks-with-3-and-4-pages/1209/2 "2018-08-17T13:31:33Z")

</div>

Have you tried using `imread`?

You are specifying the type of image and number of dimensions of the output image as the “template” parameters to ImageFileReader. Some times you need to get the Image information from the [ImageIO](https://itk.org/Doxygen/html/classitk_1_1ImageIOBase.html), then determine what the pixel type and dimension should be. The `imread` method should do some of that for you.

I am more familiar with SimpleITK so out of curiosity, have you tried reading the image with SimpleITK? Does it read it as expected? What type do you get?

If you can use the utility `tiffinfo` on the file to print the tags and dictionary that would be helpful to understand the structure of the file.

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [August 18, 2018, 9:24pm UTC](https://discourse.itk.org/t/python-read-tiff-stacks-with-3-and-4-pages/1209/3 "2018-08-18T21:24:32Z")

</div>

More details on `itk.imread`:

The image can be loaded with a default pixel type:

```auto
image = itk.imread('images.tif')

```

Check the type with:

```auto
print(type(image))

```

or, force an `unsigned char` pixel type:

```auto
image = itk.imread('images.tif', itk.UC)

```

or, force an RGB pixel type:

```auto
image = itk.imread('images.tif', itk.RGBPixel[itk.UC])

```

or, read in as an `itk.VectorImage`,

```auto
Dimension = 2
ImageType = itk.VectorImage[itk.UC, Dimension]
reader = itk.ImageFileReader[ImageType].New(FileName='images.tif')
reader.Update()
image = reader.GetOutput()

```

---

<div class="post-metadata">

### Author: ![JayKay](https://discourse.itk.org/letter_avatar_proxy/v4/letter/j/54ee81/32.png) [@JayKay](https://discourse.itk.org/u/JayKay)
#### Post date: [August 24, 2018, 11:33am UTC](https://discourse.itk.org/t/python-read-tiff-stacks-with-3-and-4-pages/1209/4 "2018-08-24T11:33:56Z")

</div>

Thanks alot! using

`itk.imread('images.tif', itk.F)`

works fine.
