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()
?
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)
skimage.util.img_as_ubyte
is a replacement for scipy.misc.bytescale
the scipy.misc.bytescale
doc states the following:
Byte scaling means converting the input image to uint8 dtype and scaling the range to (low, high) (default 0-255). If the input image already has dtype uint8, no scaling is done.
the skimage.util.img_as_ubyte
doc states the following:
Convert an image to 8-bit unsigned integer format. Negative input values will be clipped. Positive values are scaled between 0 and 255.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With