# write a tif file

**URL:** https://discourse.itk.org/t/write-a-tif-file/4923
**Category:** Beginner Questions
**Tags:** simpleitk
**Created:** [April 19, 2022, 9:57am UTC](https://discourse.itk.org/t/write-a-tif-file/4923 "2022-04-19T09:57:23Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![assia855](https://discourse.itk.org/user_avatar/discourse.itk.org/assia855/32/2642_2.png) [@assia855](https://discourse.itk.org/u/assia855)
#### Post date: [April 19, 2022, 9:57am UTC](https://discourse.itk.org/t/write-a-tif-file/4923/1 "2022-04-19T09:57:23Z")

</div>

Hello, I’m trying to save my processed data in tif format using this code, but all what I got is a black image. any suggestion to solve this error. thanks in advance.

`  
writer = sitk.ImageFileWriter()

writer.SetFileName(‘opened\_otsu’+ ‘tif’)  
writer.Execute(opened)  
`

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [April 19, 2022, 1:03pm UTC](https://discourse.itk.org/t/write-a-tif-file/4923/2 "2022-04-19T13:03:16Z")

</div>

Are you sure it’s totally black? It could be that the pixels are just all very low intensity. I’d suggest getting a histogram of the image and looking at the values in that. Or load view it in Fiji/ImageJ and window and level the image.

---

<div class="post-metadata">

### Author: ![assia855](https://discourse.itk.org/user_avatar/discourse.itk.org/assia855/32/2642_2.png) [@assia855](https://discourse.itk.org/u/assia855)
#### Post date: [April 19, 2022, 1:32pm UTC](https://discourse.itk.org/t/write-a-tif-file/4923/3 "2022-04-19T13:32:57Z")

</div>

You’re right that it wasn’t completely white, it’s just that it has a very low intensity, but I also changed the extension to nrrd with tif I couldn’t have the same view as I had with myshow3d plot. Any idea please on how can I visualize it on Fiji with tuf format.

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [April 19, 2022, 1:44pm UTC](https://discourse.itk.org/t/write-a-tif-file/4923/4 "2022-04-19T13:44:53Z")

</div>

I just used SimpleITK’s Show function, and if you have Fiji/ImageJ installed in a known location, SimpleITK will find it. For example:

```
sitk.Show(opened)
```

---

<div class="post-metadata">

### Author: ![assia855](https://discourse.itk.org/user_avatar/discourse.itk.org/assia855/32/2642_2.png) [@assia855](https://discourse.itk.org/u/assia855)
#### Post date: [April 19, 2022, 1:45pm UTC](https://discourse.itk.org/t/write-a-tif-file/4923/5 "2022-04-19T13:45:45Z")

</div>

Thank you, but I would like to save it as well in tif format.

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [April 19, 2022, 1:47pm UTC](https://discourse.itk.org/t/write-a-tif-file/4923/6 "2022-04-19T13:47:36Z")

</div>

In my case, I just wrote myself a little ‘show’ python script. Then any file on the command line is read by SimpleITK and sent to Fiji.

> <https://github.com/dave3d/SimpleITKUtilities/blob/main/show.py>

---

<div class="post-metadata">

### Author: ![assia855](https://discourse.itk.org/user_avatar/discourse.itk.org/assia855/32/2642_2.png) [@assia855](https://discourse.itk.org/u/assia855)
#### Post date: [April 19, 2022, 2:02pm UTC](https://discourse.itk.org/t/write-a-tif-file/4923/7 "2022-04-19T14:02:25Z")

</div>

Thanks. I will give it a try
