datacarpentry / image-processing

Image Processing with Python
https://datacarpentry.org/image-processing
Other
104 stars 125 forks source link

Fix call to img_as_ubyte #232

Closed iimog closed 2 years ago

iimog commented 2 years ago

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

mkcor commented 2 years ago

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

iimog commented 2 years ago

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 commented 2 years ago

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.

mkcor commented 2 years ago

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

tobyhodges commented 2 years ago

Thank you @iimog 🙌