color-space icon indicating copy to clipboard operation
color-space copied to clipboard

Query regarding TSL color space implementation

Open blaine12100 opened this issue 2 years ago • 2 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?

blaine12100 avatar Aug 08 '23 11:08 blaine12100

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.

dy avatar Aug 09 '23 12:08 dy

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 https://github.com/colorjs/color-space/blob/9687f77a0c95cdf37bba7ef7aa0fb35237446472/tsl.js#L76.

Artoria2e5 avatar Aug 09 '23 13:08 Artoria2e5