lucasb-eyer / go-colorful

A library for playing with colors in go (golang).
MIT License
1.16k stars 59 forks source link

Dramatically improve "Fast" linear-RGB conversions. #20

Closed lucasb-eyer closed 7 years ago

lucasb-eyer commented 7 years ago

This is following the discussion in #18. Documentation and a notebook for deriving the constants will follow.

lucasb-eyer commented 7 years ago

For reference, the benchmark values on my laptop (i7) are:

><((("> go test -bench .
Testing up to 100 palettes may take a while...
Done with that, but more tests to run.
BenchmarkColorToLinear-8         5000000           335 ns/op
BenchmarkFastColorToLinear-8    20000000            75.6 ns/op
BenchmarkLinearToColor-8         5000000           334 ns/op
BenchmarkFastLinearToColor-8    20000000            83.4 ns/op
PASS
ok      github.com/lucasb-eyer/go-colorful  21.607s

which I'd call a success, given the accuracy is still within ~2 RGB values (out of 255)

Ravenslofty commented 7 years ago

Very well done! It's actually beginning to look feasible to try out using L*a*b* in a large(ish) render. I do have a few algorithmic flaws of my own to try to resolve, like comparing a pair of points multiple times in a pass, but still, thank you very much!

Ravenslofty commented 7 years ago

You misspelt "tight" in 43afed8, @lucasb-eyer.

lucasb-eyer commented 7 years ago

Oh, thanks for pointing out the typo, I missed that comment! Will fix in master.