Skip to content

LoadImaged for 2D/3D grayscale tiff files #3858

@perlmutter

Description

@perlmutter

Using LoadImaged on a 2D grayscale tiff file with WSIReader and backend=cucim returns an array with 3 "color" channels, which are all identical.

For example,

data_dict = {"image": "test.tif"}
x = np.random.randint(low=0,high=256,size=(128,128),dtype=np.uint8)
io.imsave(data_dict["image"],x) 

print("cucim: shape = " + str(cucim.CuImage(data_dict["image"]).shape))
transform = LoadImaged(keys=["image"], reader=WSIReader, backend='cuCIM')
print("LoadImaged-cucim: shape = " + str(transform(data_dict)["image"].shape))

returns,

cucim: shape = [128, 128, 1]
LoadImaged-cucim: shape = (3, 128, 128)

When using backend=tifffile the files are misread entirely

print("tifffule: shape = " + str(tifffile.imread(data_dict["image"]).shape))
transform = LoadImaged(keys=["image"], reader=WSIReader, backend='tifffile')
print("LoadImaged-tifffile: shape = " + str(transform(data_dict)["image"].shape))

returns,

tifffule: shape = (128, 128)
LoadImaged-tifffile: shape = (3, 128)

Is this the expected behavior? Is there a better way to read 2D grayscale tiff files into monai? How about 3D grayscale tiffs?

Thanks,
David

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions