fix: gamma precision - #5038
Conversation
In some cases, we need more precise gamma values, while the existing rounding operation loses most of the precision. This change will continue to use rounded values to calculate and store color space information, but retain the original value in the "Gamma" parameter. Signed-off-by: Lumina Wang <lumina.wang@autodesk.com>
|
|
|
I think this is ok, but am curious about the circumstances in which rounding to 2 digits was insufficient. What gamma values are you getting in practice that show a precision problem? I have to admit, I've seen gamma values of 1.8, 2.2, 2.4, and so on. I don't recall coming across files with anything other than those round numbers. Are you seeing truly arbitrary numbers? How is that useful for anyone, if they are not using the handful of fairly standard values? |
|
@lgritz Thank you for your reply! |
|
OK, makes sense. Did you consider trying it in a way that still does the rounding, but simply preserve more significant figures? I think the situation I was trying to guard against is having a value like 2.19998, and if we print that (say, when displaying the metadata), many users are going to be confused or think it's silly behavior. EVERYBODY KNOWS THIS SHOULD BE GAMMA 2.2, and it seems like it would be kind to users to essentially make it "snap" to that value. That's what I was thinking at the time, anyway. With all the common values of 2.2, 2.4, etc., I thought 2 digits was enough, but you have pointed out situations where perhaps it is not. On the other hand, your change doesn't seem to alter the output of anything in the testsuite, so maybe that was a unique case I looked at years ago and in general it will be just fine without the rounding? I'm inclined to accept this as-is, but maybe if people complain, we can revisit and possibly go back to a rounding solution, but perhaps with more than 2 significant digits. |
|
Yeah. I think rounding common values like 1.8 / 2.2 / 2.4 is reasonable, as well as shortening the verbose ( In my case, I did find out rounding to 4 digits should be alright. However, if someone wants to limit the error to the range of epsilon, such as 1e-6f, then they might argue for retaining more. Given that current OIIO typically keeps the external input gamma value constant in |
Believe it or not, the canonical CIF FWIW, the PNG In truth, I do believe |
|
...but I suppose I'm cool with this for now :) Thanks Lumina! |
Absolutely. I'm expecting a lot of this to get overhauled fairly soon, and for most of our color management to rely on the standard CIF tokens, and even the "gamma" metadata will have a lot less importance, most of the time.
Of course it is. Honestly, I wouldn't be surprised to hear that for color science purposes, by definition, π = 3.15. |
This is a PR proposing to keep the gamma precision. In some cases, we need more precise gamma values, while the existing rounding operation loses most of the precision. This change will continue to use rounded values to calculate and store color space information, but retain the original value in the "Gamma" parameter. In addition, it can also tidy up existing code. I've verified with png/exif.png & python-colorconfig tests. No regression is introduced. Signed-off-by: Lumina Wang <lumina.wang@autodesk.com>
This is a PR proposing to keep the gamma precision. In some cases, we need more precise gamma values, while the existing rounding operation loses most of the precision. This change will continue to use rounded values to calculate and store color space information, but retain the original value in the "Gamma" parameter. In addition, it can also tidy up existing code. I've verified with png/exif.png & python-colorconfig tests. No regression is introduced. Signed-off-by: Lumina Wang <lumina.wang@autodesk.com> Signed-off-by: Vlad (Kuzmin) Erium <libalias@gmail.com>
This is a PR proposing to keep the gamma precision. In some cases, we need more precise gamma values, while the existing rounding operation loses most of the precision. This change will continue to use rounded values to calculate and store color space information, but retain the original value in the "Gamma" parameter. In addition, it can also tidy up existing code. I've verified with png/exif.png & python-colorconfig tests. No regression is introduced. Signed-off-by: Lumina Wang <lumina.wang@autodesk.com> Signed-off-by: Vlad <shaamaan@gmail.com>
This is a PR proposing to keep the gamma precision. In some cases, we need more precise gamma values, while the existing rounding operation loses most of the precision. This change will continue to use rounded values to calculate and store color space information, but retain the original value in the "Gamma" parameter. In addition, it can also tidy up existing code. I've verified with png/exif.png & python-colorconfig tests. No regression is introduced. Signed-off-by: Lumina Wang <lumina.wang@autodesk.com> Signed-off-by: Vlad (Kuzmin) Erium <libalias@gmail.com>
This is a PR proposing to keep the gamma precision. In some cases, we need more precise gamma values, while the existing rounding operation loses most of the precision. This change will continue to use rounded values to calculate and store color space information, but retain the original value in the "Gamma" parameter. In addition, it can also tidy up existing code. I've verified with png/exif.png & python-colorconfig tests. No regression is introduced. Signed-off-by: Lumina Wang <lumina.wang@autodesk.com> Signed-off-by: Vlad (Kuzmin) Erium <libalias@gmail.com>
This is a PR proposing to keep the gamma precision. In some cases, we need more precise gamma values, while the existing rounding operation loses most of the precision. This change will continue to use rounded values to calculate and store color space information, but retain the original value in the "Gamma" parameter. In addition, it can also tidy up existing code. I've verified with png/exif.png & python-colorconfig tests. No regression is introduced. Signed-off-by: Lumina Wang <lumina.wang@autodesk.com> Signed-off-by: Vlad (Kuzmin) Erium <libalias@gmail.com> Signed-off-by: Vlad <shaamaan@gmail.com>
This is a PR proposing to keep the gamma precision. In some cases, we need more precise gamma values, while the existing rounding operation loses most of the precision. This change will continue to use rounded values to calculate and store color space information, but retain the original value in the "Gamma" parameter. In addition, it can also tidy up existing code. I've verified with png/exif.png & python-colorconfig tests. No regression is introduced. Signed-off-by: Lumina Wang <lumina.wang@autodesk.com> Signed-off-by: Vlad (Kuzmin) Erium <libalias@gmail.com> Signed-off-by: Vlad <shaamaan@gmail.com>
Description
This is a PR proposaling to keep the gamma precision.
In some cases, we need more precise gamma values, while the existing rounding operation loses most of the precision. This change will continue to use rounded values to calculate and store color space information, but retain the original value in the "Gamma" parameter. In addition, it can also tidy up existing code.
Tests
I've verified with png/exif.png & python-colorconfig tests. No regression is introduced.
Checklist:
behavior.
testsuite.
PR, by pushing the changes to my fork and seeing that the automated CI
passed there. (Exceptions: If most tests pass and you can't figure out why
the remaining ones fail, it's ok to submit the PR and ask for help. Or if
any failures seem entirely unrelated to your change; sometimes things break
on the GitHub runners.)
fixed any problems reported by the clang-format CI test.
corresponding Python bindings. If altering ImageBufAlgo functions, I also
exposed the new functionality as oiiotool options.