How to save images? #736
-
Hello, Thank you very much for this great package. How can I save image on disk in a proper format (png, jpg...). A bit of help would be appreciated! Best, |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments
-
Hi @aurelienbl, Simply passing the Cheers, Thomas |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Oh sorry, I did not read carefully and you are not using the plotting code. In order to write a PNG or JPG, i.e. 8-bit data, image to disk, you would need to non-linearly encode the image first, e.g. Is it possible to let me know which image IO backend you are using by giving me the output of the following definition: Cheers, Thomas |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Looks like the image is compressed somehow! Let me get back to you tonight. Bests, Thomas |
Beta Was this translation helpful? Give feedback.
-
Allright, took 5 minutes to look at that, it seems like
|
Beta Was this translation helpful? Give feedback.
-
Great ! It works fine like this. Aurélien |
Beta Was this translation helpful? Give feedback.
-
You are welcome! :) |
Beta Was this translation helpful? Give feedback.
Allright, took 5 minutes to look at that, it seems like
imageio
(PIL?) is trying to be smart and whenever it has floating point data casted to 8-bit, it remaps it as follows: [min, max] --> [0, 255] thus you should do something like that:my_image = (colour.cctf_encoding(np.clip(my_image, 0, 1)) * 255).astype(np.uint8)