Thread: explanation needed in converting HSV to RGB colors

  1. #1
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694

    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?

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,633
    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
    Last edited by jimblumberg; 10-09-2012 at 03:03 PM. Reason: Edited incorrect link.

  3. #3
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Quote Originally Posted by jimblumberg View Post
    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 )

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    4,633
    Sorry about the broken link, I edited the last post and provided the correct link.

    Jim

  5. #5
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    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.

  6. #6
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    Quote Originally Posted by jimblumberg View Post
    Sorry about the broken link, I edited the last post and provided the correct link.
    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 View Post
    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

  7. #7
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    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.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  8. #8
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

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

    Soma

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Explanation of functions needed.
    By JOZZY& Wakko in forum C Programming
    Replies: 4
    Last Post: 12-16-2009, 12:09 PM
  2. Tic Tac Toe Explanation Needed
    By almister in forum C Programming
    Replies: 0
    Last Post: 08-28-2009, 12:10 PM
  3. A bit of explanation needed.
    By JacobN in forum C Programming
    Replies: 3
    Last Post: 11-24-2007, 05:41 PM
  4. strswap. Explanation needed.
    By kantze in forum C Programming
    Replies: 5
    Last Post: 10-21-2006, 10:53 AM
  5. Explanation needed, what is this?
    By CAP in forum C Programming
    Replies: 8
    Last Post: 06-25-2002, 04:07 AM