Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert exr to png file #218

Open
Youdiie opened this issue Aug 8, 2023 · 3 comments
Open

Convert exr to png file #218

Youdiie opened this issue Aug 8, 2023 · 3 comments
Labels
question Further information is requested

Comments

@Youdiie
Copy link

Youdiie commented Aug 8, 2023

I wanted to convert exr file to png file.
I used the example 1b_convert_exr_to_png, but the color of converted png file was quite different from original exr file.
exr file: (can't upload exr file, so instead screenshot)
스크린샷 2023-08-08 오후 3 07 17
converted png file:
render (4)

I found the comment does the image crate expect gamma corrected data? in tone_map function.
Is that comment related to this problem?
Any comment will be helpful!

@Youdiie Youdiie added the question Further information is requested label Aug 8, 2023
@johannesvollmer
Copy link
Owner

Hi! Yes, this might be the problem. The exr format allows many color spaces, in linear format. Most other software doesn't use linear colors.

Where do your exr images come from?

@johannesvollmer
Copy link
Owner

johannesvollmer commented Sep 19, 2023

The color differences can have many sources, but I think these are the most likely in your case:

  • "color space linear versus non-linear" The exr format stores linear colors, but PNG certainly uses non-linear sRGB colors, so you have to perform a conversion
  • "tone mapping" The exr format allows for arbitrary brightness, but PNG is only integers from 0 to 255 (or 0 to 1 floats). Thus, the example performs tone-mapping to squash the infinite values into the limited range from 0 to 1. This leads to washed out colors. You can remove this step entirely, if your image has the 0 to 1 range from the start.

@johannesvollmer
Copy link
Owner

So essentially, remove the calculations from line 45 in the example

let clamped = (linear - 0.5).tanh() * 0.5 + 0.5;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants