Search code examples
pythonscipyscikit-image

What replaces scipy.misc.bytescale?


I am running old code using scipy 1.3.1 with the following import:

from scipy.misc import bytescale

with the following error:

ImportError: cannot import name 'bytescale'

I see that bytescale has been removed since 1.3 (source). The thread suggests that the scikit-image util module would be a good replacement, but does not offer one.

What is a good alternative to the now deprecated scipy.misc.bytescale()?


Solution

  • I think there is no direct equivalent (be able to specify high and low) but you can use things like skimage.util.img_as_ubyte for scaling between 0 and 255, skimage.util.img_as_uint for scaling between 0 and 65535. Check them here: https://scikit-image.org/docs/stable/api/skimage.util.html (The img_as_* stuffs)