cucim icon indicating copy to clipboard operation
cucim copied to clipboard

Images with no color channel!

Open drbeh opened this issue 2 years ago • 5 comments

Describe the bug When using cuCIM to load TIFF files that does not have color channel (a grayscale 2D image), no error is thrown and instead the values will be repeated to create an RGBA image, representing the grayscale image. This may cause confusion, like here: https://github.com/Project-MONAI/MONAI/issues/3858

Steps/Code to reproduce bug

import numpy as np                                                                                                                                                                                                                           
from skimage import io    
from cucim import CuImage

image_path = "test.tif"
x = np.random.randint(low=0, high=256, size=(128,128), dtype=np.uint8)
io.imsave(image_path, x) 

img = np.array(CuImage(image_path).read_region())
print(f"{img.shape = }")
print(f"{img[0, 0, :] = }")
img.shape = (128, 128, 4)
img[0, 0, :] = array([121, 121, 121, 255], dtype=uint8)

drbeh avatar Mar 01 '22 17:03 drbeh

@gigony is there any update on this? thanks

drbeh avatar Mar 22 '22 17:03 drbeh

@drbeh we would eventually need to support multi-band and other data types

  • https://github.com/rapidsai/cucim/issues/33

Currently, if the image is not RAW/LZW/JPEG/JPEG2000-compressed tiled/multi-resolution RGB images, it delegates its processing to libtiff's TIFFRGBAImageGet() method that creates a 4-channel RGBA array.

What would you suggest until we support single-channel image data? Maybe raising a warning message would be one we can do?

gigony avatar Apr 05 '22 18:04 gigony

Thank you, @gigony! Raising an error would satisfy the purpose of this open issue. Currently, we don't have any need for single-channel images in digital pathology but it might be a good feature to have.

drbeh avatar Apr 05 '22 20:04 drbeh

Thank you, @gigony! Raising an error would satisfy the purpose of this open issue. Currently, we don't have any need for single-channel images in digital pathology but it might be a good feature to have.

Now raising a warning message (by https://github.com/rapidsai/cucim/pull/293) and updated tag from bug to feature request.

gigony avatar Oct 17 '23 20:10 gigony

Currently, we don't have any need for single-channel images in digital pathology but it might be a good feature to have.

One use case would be where another imaging modality is used, such as higher harmonic generation microscopy, from which we only want to fetch one channel, as the other channels might sometimes be undescriptive and might confuse deep learning models.

Another use case is when a mask's pixels intensity serve as labels. If high resolution masks are available, it might still be beneficial to read them with cucim.

siemdejong avatar Feb 08 '24 15:02 siemdejong