Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.