Hello,
I would say there are two differences between 'Saving the data' and 'Displaying the data'. An image is discretized to `uint8` or `uint16` prior to being saved as standard formates (`.png` or `.jpg`). You could do something like
```But you will find some discretization errors, which makes `B != A`. Having said that, if you want to preserve the data in `B`, I think the best option is to export the data using another format, e.g. numpy arrays:
```Or alternatively, if you really want to save the data in a visualizable format, exporting the image as `.tif` format, which preserves data information, should also work:
```However, I would personally store my data in non-visualizable
formats such as `.npy, .h5` (the later if you work with tons of
data) as they usually offer another advantages (e.g. Datasets in
HDF5).
Hope it helps,
Imanol
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 typefloat32 and shape (128,128)
, the maximum value is1.0
and the minimum value is0.0.
I saved it usingio.imsave(‘mask_image’,temp_mask)
However, after I re-opened this image usingimg_mask = io.imread(‘mask_image’)
. The read image turns out to have typeunit16
, the max value becomes6553
5 and the min value is0
. 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!
_______________________________________________ scikit-image mailing list scikit-image@python.org https://mail.python.org/mailman/listinfo/scikit-image
This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system, you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.