RGB to TLS conversion

B2kguga

New member
Joined
Apr 29, 2017
Messages
4
Hello

Someone knows what is the reverse operation involving a TSL to RGB colospace transformation ?

According to wikipedia, the math operations related to RGB to TSL transformation (Tint, Saturation and Light) are made like this formula:
TSL1.jpg

But...the solution they presented to revert back the formula is not correct. What is the correct math involving the revert operation in order to we allow the transformation from TSL to RGB ?

Btw...the link from wiki where this formulas can be accessed is this
https://en.wikipedia.org/wiki/TSL_color_space

Many thanks, in advance.
 
Last edited:
Hello

Someone knows what is the reverse operation involving a TSL to RGB colospace transformation ?

According to wikipedia, the math operations related to RGB to TSL transformation (Tint, Saturation and Light) are made like this formula:

. . .\(\displaystyle T\, =\, \begin{cases}\frac{1}{2\pi}\,\arctan\, \frac{r'}{g'}\, +\, \frac{1}{4},&\mbox{ if }\, g'\, >\, 0 \\ \frac{1}{2\pi}\,\arctan\, \frac{r'}{g'}\, +\, \frac{3}{4},&\mbox{ if }\, g'\, <\, 0 \\ 0,&\mbox{ if }\, g'\, =\, 0 \end{cases}\)

. . .\(\displaystyle S\, =\, \sqrt{\strut \frac{9}{5}\, (r'^2\, +\, g'^2)\,}\)

. . .\(\displaystyle L\, =\, 0.299R\, +\, 0.587G\, +\, 0.114B\)

. . .where:

. . .\(\displaystyle r'\, =\, r\, -\, \frac{1}{3}\)

. . .\(\displaystyle g'\, =\, g\, -\, \frac{1}{3}\)

. . .\(\displaystyle r\, =\, \frac{R}{R\, +\, B\, +\, G}\)

. . .\(\displaystyle g\, =\, \frac{G}{R\, +\, B\, +\, G}\)

But...the solution they presented to revert back the formula is not correct. What is the correct math involving the revert operation in order to we allow the transformation from TSL to RGB ?
On what basis had you concluded that the reversion formulae were incorrect?

When you reply, please clarify whether or not the 1/4 and 3/4 are included inside the arctangents. Thank you! ;)
 
Thanks for the reply.

the addition of 1/4 and 3/4 are not inside the arctangents.

The formula calculates the value of arctangent (r'/g') then divide by 2*Pi and then add 1/4 or 3/4.

The reversed formula is incorrect. I tested it using
Red = 128
Green = 22
Blue = 37

Once it found the values of Tint (T), Light and Saturation, i tested the reversed transformation using the formula on wiki and the resultants R, G, B were completely different. Also, one of the values were negative (which is impossible, since RGB varies from 0 to 255 or 0 to 1 - normalized) and other value have a value way higher then 255

On wiki comments there is a tab labeled as "talk". In there people also are saying that the resultant value of the reverse transformation is incorrect. The person who posted the reversed transformation (TLS to RGB) simply guessed the formula as he said. He also said that one of the terms he used to revert the operations are still wrong.
 
Last edited:
Hi guys...not sure if ti will help finding the proper solution, but, maybe i found some properties of the function.

I´m making some tests on the excel spreadsheet and reading a pdf about a IHS2 colorspace that i found here: https://arxiv.org/ftp/arxiv/papers/1107/1107.4396.pdf

For what i saw so far, there seems to exist a constant value when computing this:

S*cos(2*pi*T) / r’ = -3/sqrt(5) (equation1)
S*sin(2*pi*T) / g’ = 3/sqrt(5) (equation2)

Dividing Equation2 from Equation1 we have:

(r'* tan(2 *PI* T))/g' = -1

then, unrolling we find this

tan(2 *PI* T)= -g'/r'
 
Last edited:
Top