# explanation needed in converting HSV to RGB colors

• 10-09-2012
std10093
explanation needed in converting HSV to RGB colors
Hello everybody,

in one project i have now ,i have to go from HSV color to RGB.Ok i found the algorithm algo
but i do not wan just to copy paste it .I think it is a real chance for me to understand how this thing works,or to become more accurate,why this is the algorithm?How could someone came up with this if he did not find it?
• 10-09-2012
jimblumberg
Quote:

How could someone came up with this if he did not find it?
Through the brilliance of the human mind, someone came up with a way to encode a "color" into a discrete numeric value. It appears that George H. Joblove and Donald Greenberg were the originators of this particular formula. See this link: HSL and HSV WiKi. In the further reading section this link provides several authoritative references you can purchase.

Jim
• 10-09-2012
std10093
Quote:

Originally Posted by jimblumberg
Through the brilliance of the human mind, someone came up with a way to encode a "color" into a discrete numeric value. It appears that George H. Joblove and Donald Greenberg were the originators of this particular formula. See this link: HSL and HSV WiKi. In the further reading section this link provides several authoritative references you can purchase.

Jim

Hello Jim,

unfortunately the link does not work.(maybe only for me).But ok , i do really believe that is worth purchasing books or something similar for this . (student yet :) )
• 10-09-2012
jimblumberg

Jim
• 10-09-2012
anduril462
Did you ever take a class where you had to convert from rectangular coordinates (x, y) to circular (r, theta)? That's basically what you're doing with RGB->HSV but it's in three dimensions. I tend to think of RGB as a cube, where the R, G and B coordinates might be (x, y, z) respectively. HSV/HSL as cones or cylinders (I suppose cylinders is easiest for coordinate transformation). Hue is the angle (theta), saturation is the radius and value/luminosity the height.

Then you're just applying transformations to the coordinates, similar to how you do
Code:

```r = sqrt(x*x + y*y) theta = inverse_tan(y / x) // or in reverse x = r cos(theta) y = r sin(theta)```
It's the same concept for HSV <-> RGB, but a bit more complicated.
• 10-09-2012
std10093
Quote:

Originally Posted by jimblumberg
Jim

Thank you jim for the updated link, but it is the same as the one i posted in my first post :)
Quote:

Originally Posted by anduril462
Did you ever take a class where you had to convert from rectangular coordinates (x, y) to circular (r, theta)? That's basically what you're doing with RGB->HSV but it's in three dimensions. I tend to think of RGB as a cube, where the R, G and B coordinates might be (x, y, z) respectively. HSV/HSL as cones or cylinders (I suppose cylinders is easiest for coordinate transformation). Hue is the angle (theta), saturation is the radius and value/luminosity the height.

Then you're just applying transformations to the coordinates, similar to how you do
Code:

```r = sqrt(x*x + y*y) theta = inverse_tan(y / x) // or in reverse x = r cos(theta) y = r sin(theta)```
It's the same concept for HSV <-> RGB, but a bit more complicated.

Yes i have.I think that this is the path to understand the algorithm :-D
Cube for RGB and cone for HSV,not cylinder :)
• 10-10-2012
brewbuck
Why is "x + y" the formula for adding two numbers together?

The answer is, because we get to decide what "adding" means, and what the "+" symbol means.

You're asking why the formula for RGB to HSV is the way it is, when in fact the formula is what defines HSV in relation to RGB and therefore your question contains no substance.

Short answer: the formula is what it is, because we say so.
• 10-10-2012
phantomotap
O_o

Exactly that is why it bothers me that some things (like matrix multiplication) have ever seen a patent.

Soma