Closed
Labels
Description
scikit-image/skimage/color/colorconv.py
Line 152 in ac4a8f1
| if arr.ndim not in [3, 4] or arr.shape[-1] != 3: |
The line above only allows you to have 4D multichannel arrays.
Would you accept patches that ensures that we can work with ND multichannel arrays?
This is useful for example when you are trying to stitch tiles of acquired images with a microscope.
You might have large arrays, each RGB (3 dimensions) tiled in the x, y, and time dimension.
6 dimensions! I'm sure somebody could think of more.
I know there is talk about using an other backend for color conversion, but the skimage color backend seems to do the trick for now.
Activity
jni commentedon Jun 13, 2018
Yes that line is super hacky! I was actually just thinking of this very line of code!!! LOL
If you can find a way to fix it without breaking backwards compatibility, we would welcome that very much. Otherwise we might have to go through a deprecation path.
The main question is whether we want to keep the behaviour of
gray2rgb(rgbimage)being a no-op. It's kind of nice and I've used it a few times, but it's hard to implement if we want to support arbitrarily-shaped nd arrays.But, either way, that line has to go. It's very magical behaviour, and, what's worse, there's no way to turn the magic off.
hmaarrfk commentedon Jun 13, 2018
it seems that the parameter
multichannelhas been used to simplify the guessing logic.Maybe we can issue warnings to deprecate the old behaviour
For example: I'm thinking of the following docstring for
rgb2grayhmaarrfk commentedon Jun 13, 2018
Why is this logic the way it is in the function
guess_spatial_dimensions? It seems in both cases it should beNonemaybe?https://github.com/scikit-image/scikit-image/blob/master/skimage/color/colorconv.py#L87
stefanv commentedon Jun 13, 2018
I tend to agree.
hmaarrfk commentedon Jun 13, 2018
Seems like it is only used in
filters.gaussianrfezzani commentedon Jan 28, 2020
My solution to this issue is may be a little bit radical: I consider that
multichannelis implicitlyTruefor all the functions butgray2rgb,rgb2graydoes not accept gray level images,rgb2graydoes not accept RGBA imagesI implemented It in #4418. It allows to easily add nD support using
Ellipsisand alleviates all the "guessing"...