-
Notifications
You must be signed in to change notification settings - Fork 4
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
Negative clause in linearize-srgb and delinearize-srgb #10
Comments
Hi. As in docstring written, it is actually the same formula as bg-sRGB, that extends the range of sRGB ([-0.53, 1.68] instead of [0, 1]). |
All right! Understood. I read the comment, but didn't know, what bg-sRGB means. And I didn't google for it. Sorry. As you wrote earlier, you prefer multiple values over lists for better performance. But here you do one comparision more that necessary (for sRGB) - for each color once, which gives millions for a real color image. Would not it be better to have one pair of linearizer/delinearizer for sRGB and another for bg-SRGB. Although the code is largely identical. |
You might mean (defun linearize-srgb-faster (x)
(declare (optimize (speed 3) (safety 1))
(double-float x))
(if(> x #.(* 0.0031308d0 12.92d0))
(expt (* (+ 0.055d0 x) #.(/ 1.055d0)) 2.4d0)
(* x #.(/ 12.92d0)))) Though in reality it makes little difference in speed when doing
or something alike. (Of course, it's because almost all values here are processed in the first case.) |
Additional remark: |
The cond in linearize-srgb have a negative clause for x < -0.040449936d0 (exactly: (* -0.0031308d0 12.92d0)). You make similar computation in delinearize-srgb. Why? I've never seen such a formula (negative term). Neither in wikipedia, nor Bruce Lindbloom, nor other sources (e.g. https://www.w3.org/Graphics/Color/srgb.pdf).
The text was updated successfully, but these errors were encountered: