Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

label2rgb raises a wrong message when inputs are 3D #5501

Open
patquem opened this issue Aug 4, 2021 · 2 comments
Open

label2rgb raises a wrong message when inputs are 3D #5501

patquem opened this issue Aug 4, 2021 · 2 comments

Comments

@patquem
Copy link
Contributor

patquem commented Aug 4, 2021

Hi,
the 2D-test presented in #4657 doesn't work when extended in 3D.
Is this a bug ?
Thanks,
Patrick

version : scikit-image-0.18.2

import numpy as np
from skimage.color import label2rgb

img = np.random.randint(0, 255, (10, 10, 10), dtype=np.uint8)
labels = np.zeros((10, 10, 10), dtype=np.uint8)
labels[:, 1:3, 1:3] = 1
labels[:, 6:9, 6:9] = 2
color = label2rgb(labels, image=img, bg_color=(0,0,0), bg_label=0)

raise ValueError("image and label must be the same shape") (in skimage\color\colorlabel.py line 162)

@rfezzani rfezzani changed the title Bug in label2rgb in 3D label2rgb raises a wrong message when inputs are 3D Aug 4, 2021
@rfezzani
Copy link
Member

rfezzani commented Aug 4, 2021

According to its documentation, label2rgb only supports 2D inputs: label and image must be respectively of shape (M, N) and (M, N, 3). But this can be effectively checked to raise a proper error message.
I modified your issue title to reflect this. Thank you for the report.

@patquem
Copy link
Contributor Author

patquem commented Aug 4, 2021

thanks for the reply @rfezzani .
I agree with you (doc + issue title).
As skimage.measure.label works whatever the array size, it could be good to have label2rgb working in 3D (or whatever the dimension, if this has sense), couldn't it ?
(+ type:enhancement ??)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants