comic / evalutils

evalutils helps users create extensions for grand-challenge.org
https://grand-challenge.org
MIT License
23 stars 9 forks source link

how should we load tiff files (SimpleITK introduced new values) #338

Closed JunMa11 closed 2 years ago

JunMa11 commented 2 years ago

Description

I'm creating an evaluation docker for an image segmentation task. The ground truth data is tiff format. I found SimpleITK introduced new values after loading.

import tifffile as tif
import SimpleITK as sitk
import numpy as np

gt1 = tif.imread('/path to/cell_00001_label.tiff')
print('gt1', np.unique(gt1))
gt2 = sitk.ReadImage('/path to/cell_00001_label.tiff')
print('gt2', np.unique(sitk.GetArrayFromImage(gt2)))

outputs:

gt1 [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]

gt2 [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 32737, 1735658464]

The above image is available here

How can I read images with tifffile in evaluation.py?

jmsmkn commented 2 years ago

TIFF should be supported by imageio: https://imageio.readthedocs.io/en/stable/formats/index.html

You can try using the built in imageio loader: https://github.com/comic/evalutils/blob/73ba4ceae361557c70992245b16463159d6bfba0/evalutils/io.py#L136-L145

Note that these all load the image data into memory so it may not be what you want, depends on the size of your tiff files. You could create your own loader using tifffile, follow the examples in io.py.