image-processing icon indicating copy to clipboard operation
image-processing copied to clipboard

Fix call to img_as_ubyte

Open iimog opened this issue 2 years ago • 4 comments

The function img_as_ubyte needs to be called as skimage.util.img_as_ubyte. The util part was sometimes missing.

iimog avatar Sep 29 '22 12:09 iimog

No, it's not necessary: I just checked and I could equally from skimage import img_as_ubyte and from skimage.util import img_as_ubyte. I guess the magic is happening here: https://github.com/scikit-image/scikit-image/blob/533a5b5c0852b38890d63c348117aba8055b3995/skimage/init.py#L152-L158

mkcor avatar Oct 05 '22 13:10 mkcor

Nice, I did not know that. I still think it is better to call it consistently (either with or without util). I think it fits slightly better to use the util submodule as most other functions are called from submodules as well. But I'm happy to discuss the pro and cons.

iimog avatar Oct 05 '22 13:10 iimog

Your comment also made me realize, that in the "Resizing an image" box, we need to also import skimage.util or import skimage. Otherwise, neither of the ways to call img_as_ubyte will work.

iimog avatar Oct 05 '22 13:10 iimog

You are right that, for educational purposes, it's probably better to keep the util submodule explicit.

mkcor avatar Oct 05 '22 18:10 mkcor

Thank you @iimog 🙌

tobyhodges avatar Oct 31 '22 08:10 tobyhodges