how to correctly save an numpy array with float32 type into an image
Dear All, In a program, I generate an numpy array, with shape (128,128), which is supposed to represent an image. For instance, I have an array temp_mask, which is of type float32 and shape (128,128), the maximum value is 1.0 and the minimum value is 0.0. I saved it using io.imsave(‘mask_image’,temp_mask) However, after I re-opened this image using img_mask = io.imread(‘mask_image’). The read image turns out to have type unit16, the max value becomes 65535 and the min value is 0 . It seems to me that io.imsave automatically transform the float32 array into an unit16 array. Is it possible to save the image while keeping the original type? If not, what’s the correct way to save an image represented as an array, with type float32 and the range of value [0.0,1.0]? Thank you very much!
participants (1)
-
wine lover