Help triplets to 2d conversion formula

  • Thread starter Thread starter metalfred
  • Start date Start date
  • Tags Tags
    2d Formula
AI Thread Summary
The discussion focuses on converting RGB pixel colors into 2D XY coordinates for a software development project. The user provides specific coordinates for primary colors and asks for a formula to achieve the conversion. A suggested formula is presented: (x, y) = R/255 * (-26, -100) + G/255 * (-50, 76) + B/255 * (62, 10), which utilizes the RGB values to calculate the coordinates. The conversation clarifies that black and white should have distinct coordinates, correcting an earlier mistake. The proposed method allows for accurate mapping of color values to their respective positions in a 2D space.
metalfred
Messages
2
Reaction score
0
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 a lot of the help ! *pulling hair* :)

-fred
 
Physics news on Phys.org
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.
 
Thanks a lot Mark for your help! I reall appreciate ;)

-fred
 
I picked up this problem from the Schaum's series book titled "College Mathematics" by Ayres/Schmidt. It is a solved problem in the book. But what surprised me was that the solution to this problem was given in one line without any explanation. I could, therefore, not understand how the given one-line solution was reached. The one-line solution in the book says: The equation is ##x \cos{\omega} +y \sin{\omega} - 5 = 0##, ##\omega## being the parameter. From my side, the only thing I could...
Essentially I just have this problem that I'm stuck on, on a sheet about complex numbers: Show that, for ##|r|<1,## $$1+r\cos(x)+r^2\cos(2x)+r^3\cos(3x)...=\frac{1-r\cos(x)}{1-2r\cos(x)+r^2}$$ My first thought was to express it as a geometric series, where the real part of the sum of the series would be the series you see above: $$1+re^{ix}+r^2e^{2ix}+r^3e^{3ix}...$$ The sum of this series is just: $$\frac{(re^{ix})^n-1}{re^{ix} - 1}$$ I'm having some trouble trying to figure out what to...
Back
Top