cucim
cucim copied to clipboard
Images with no color channel!
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)
@gigony is there any update on this? thanks
@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?
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.
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
.
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.