colour-science / colour-demosaicing

CFA (Colour Filter Array) demosaicing algorithms for Python
https://www.colour-science.org
BSD 3-Clause "New" or "Revised" License
285 stars 58 forks source link

How to save the image correctly? #18

Closed yyuuliang closed 3 years ago

yyuuliang commented 3 years ago

hi thanks for this lib. I have a question about saving img. I can use the plot to plot a correct color img, however, I don't know how to save it correctly. The color in the saved img is quite different from the plotting. Will you please show a example of img saving?

KelSolaar commented 3 years ago

Hi @yyuuliang,

So assuming you have an image:

image = demosaicing_CFA_Bayer_Malvar2004(CFA)

It is float64 linear at this stage, so you could either save it as an EXR linear file:

colour.write_image(image, 'my_image.exr')

or as a PNG file, but this would require non-linear encoding, e.g. sRGB:

colour.write_image(colour.cctf_encoding(image), 'my_image.png')