1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help triplets to 2d conversion formula

  1. Jan 26, 2009 #1
    Hi all,

    I am learning software development and I need to do something that requires some pretty good mathematics I think. I am not very good and been working to solve this problem for a few days now, any help is appreciated.

    Here is what I am doing:


    I need to find a way to convert pixel colors (rgb) into a 2d xy coordinates.


    I know that the perfect red (255, 0, 0) color is at this position:


    rx = -26;
    ry = -100;


    I know that the perfect green (0, 255, 0) color is at this position:


    gx = -50
    gy = 76


    I know that the perfect blue (0, 0, 255) color is at this position:


    bx = 62;
    by = 10;


    I know that white (0, 0, 0) is at this position:


    wx = 0;
    wy = 0;


    I know that black (255, 255, 255) is at this position:


    blx = 0;
    bly = 0;


    Now I need to figure our the formula to convert something like:

    (234, 23, 54) to a X Y position.



    This is an image of what I am developing, I have something that works right now but the formula is not right.

    Vectorscope:

    http://www.codeguru.com/forum/attachment.php?attachmentid=24192&stc=1&d=123284865


    Can this be done ? Impossible maybe ?

    Thanks alot of the help !!! *pulling hair* :)

    -fred
     
  2. jcsd
  3. Jan 27, 2009 #2

    Mark44

    Staff: Mentor

    I have an idea that might be helpful, but first a couple of comments:
    I don't see that it's helpful to embed color information in the names of the x and y coordinates; e.g., bx, gx, rx, by, and so on. Just call them x and y.
    You show black and white as having the same (x, y) coordinates. Presumably that's a mistake. The color triple for white should be (255, 255, 255) and for black it should be (0, 0, 0). White is the presence of all colors, and black the absence of them all (visible light--pigments are different).

    I drew an x,y coordinate system and plotted points for red, green, and blue, namely (-26, -100), (-50, 76), and (62, 10) respectively. These points can be considered the endpoints of vectors that extend from the origin.

    The three vectors divide the plane into more-or-less equal thirds.

    To convert a color triple (R, G, B) into (x, y) coordinates, you can use this formula:

    (x, y) = R/255 *(-26, 100) + G/255 * (-50, 76) + B/255 * (62, 10)

    For example, your true blue is (0, 0, 255), so
    (x, y) = 0 + 0 + 1 * (62, 10) = (62, 10)

    A mix of green and blue is (0, 255, 255), so
    (x, y) = 0 + 1 * (-50, 76) + 1 * (62, 10) = (12, 86)

    Black (which I'm calling (0, 0, 0)) works out fine, but I don't also get (0, 0) for white.
     
  4. Jan 27, 2009 #3
    Thanks alot Mark for your help! I reall appreciate ;)

    -fred
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Help triplets to 2d conversion formula
  1. Summation formula help (Replies: 2)

Loading...