-
Notifications
You must be signed in to change notification settings - Fork 1
Description
The Image data layer has a rgb attribute which can be set to True to indicate that the image should be in RGB format.
This means that, when an input image parameter has rgb set to True, passing a non-RGB image (e.g. grayscale) will raise a ValidationError.
@sk.algorithm
def rgb_algo(image=sk.Image(rgb=True)):
...Another effect is that the pixel domain of the RGB image effectively corresponds to its XY spatial domain (ignoring the colour channel).
img = sk.Image(np.zeros((100, 100, 3)), rgb=True)
print(img.pixel_domain()) # (100, 100)This makes it possible to compute segmentation masks tile-by-tile using RGB images as input (e.g. StarDist on a H&E image) with the segmentation mask correctly having a 2D shape.
However, when an algorithm is designed to work with both RGB and grayscale images, we maintain rgb to False to allow grayscale images. However, when running such an algorithm in tiling mode, an RGB image becomes wrongly interpreted as a 3D image, leading to an error when attempting to merge tiles.
For now, not sure how to best solve this conondrum. I suppose that in the future, if we introduce an explicit way of labeling image axes (CTZYX, etc.), this may help to solve this kind of issues.