Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scipy imsave and imread change format

When I save the image, the format it has is numpy.uint16, when I load it, it is numpy.uint8, and it messes up the whole pipeline for me. How do I prevent this from happening?

I am calling

from scipy.misc import imread, imsave
image = imread(path)
imread(image_path)
like image 945
Baron Yugovich Avatar asked Nov 24 '25 05:11

Baron Yugovich


1 Answers

The imsave and imread methods are deprecated and will be removed in future versions of SciPy. Using imageio.imwrite and imageio.imread instead should solve this.

>>> import imageio
>>> img = imageio.imread('img.jpg')
>>> img.dtype
dtype('uint8')
>>> imageio.imwrite('img_saved.jpg', img)
>>> img_read = imageio.imread('img_saved.jpg')
>>> img_read.dtype
dtype('uint8')
like image 184
Lakshay Sharma Avatar answered Nov 25 '25 20:11

Lakshay Sharma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!