colorjs / color-space

Math & data behind color spaces and color conversions.

Home Page:http://colorjs.github.io/color-space

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Query regarding TSL color space implementation

blaine12100 opened this issue · comments

Hi

I'm trying to implement the TSL colour space in Python. I've referred to your implementation and the Wikipedia source for this. In your implementation, you do not follow the Wikipedia format entirely as it mentions that the R, G, and B values need to be gamma corrected. And even your implementation of Tint values is different. Can you shed some light on this?

About tint value - @Artoria2e5 recently made an optimization.
About difference with wiki - unfortunately I can't remember the details why it's done so. I should've commented the reasoning better. I wonder if tests fail or this solution diverges from canonical.
As for gamma-correction - there's a chance it was missed out. You're welcome to propose fix if you'd like to.
I would not use this implementation as source of truth.

I wrote both the Wikipedia bits and the code here, so these descriptions should be the same. An explanation follows.

  • Gamma correction: The input RGB color space in this repo is the web sRGB color space, which indeed is gamma corrected. "Correction" means to make the values non-linear, not to remove the gamma and make it linear.
  • Tint: They are the exact same. Compare: and
    T = g_ != 0 ? 0.5 - Math.atan2(g_, r_) / 2 / Math.PI : 0,
    .