# Reading/casting .tif images into SimpleITK

**URL:** <https://discourse.itk.org/t/reading-casting-tif-images-into-simpleitk/7683>\
**Category:** Beginner Questions\
**Tags:** simpleelastix\
**Created:** [December 18, 2025, 5:43pm UTC](https://discourse.itk.org/t/reading-casting-tif-images-into-simpleitk/7683 "2025-12-18T17:43:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rock](https://discourse.itk.org/user_avatar/discourse.itk.org/rock/32/4610_2.png) [@Rock](https://discourse.itk.org/u/Rock)\
**Post date:** [December 18, 2025, 5:43pm UTC](https://discourse.itk.org/t/reading-casting-tif-images-into-simpleitk/7683/1 "2025-12-18T17:43:26Z")

</div>

Hello,

My lab has .tif images we need to do a groupwise registration on and I am having difficulty reading them into SimpleITK. If I understand correctly, to register images they need to be floats so I have tried reading in the images as float32 and reading as tifs and then casting to float32 using this code:

import SimpleITK as sitk  
from SimpleITK import Cast as cast

fixfloat = sitk.ReadImage(“tmov.jpg”, outputPixelType = sitk.sitkFloat32)  
fix = sitk.ReadImage(“tmov.jpg”)  
fixcast = cast(fix, sitk.sitkFloat32)

The image being read is just a red triangle I made in Photoshop to test with.

[tfix.tif](https://discourse.itk.org/uploads/short-url/z62YtkG4TGWlxMR8hJf57roG363.tif) (567.1 KB)

When I read it in converting to float32, the image ends up being blank when I save it out. When I read it it in as-is, the image displays properly when saved out but when I try to cast it I get the message:

```auto
:ERROR: Filter does not support casting from casting vector of 8-bit unsigned integer to 32-bit float

```

Because of this, the image version I can register is blank and the image showing the triangle can’t be registered. I would be extremely grateful for some advice on what I am doing wrong.

Thanks very much in advance!

Rock

---

<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:** [December 18, 2025, 5:53pm UTC](https://discourse.itk.org/t/reading-casting-tif-images-into-simpleitk/7683/2 "2025-12-18T17:53:52Z")

</div>

Hello,

You are correct that the registration framework works with float and double images.

However, in simple pixel vector types are distinct from scalar pixel types. The error messages says "vector of 8-bit " so that is an indication that your `fix` image is a multi-component image and not a scalar. Since these are test images you may just want to save them as gray scale images.

You can do a “print(fix)” to look at some of the information such as the pixel type of the image. When displaying floating point images you need to be mindful of the data range ( min, max ) of the pixel and what the window the viewer is using or expecting from the data. For example Matplotlib’s imshow has vmin, and vmax parameters: [matplotlib.pyplot.imshow — Matplotlib 3.10.8 documentation](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.imshow.html)
