write a tif file

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)
`

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.

1 Like

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.

1 Like

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)
1 Like

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

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.

1 Like

Thanks. I will give it a try