Help triplets to 2d conversion formula

  • Thread starter metalfred
  • Start date
  • Tags
    2d Formula
In summary, Fred is trying to find a way to convert pixel colors (rgb) into a 2d xy coordinates. He knows that the perfect red (255, 0, 0) color is at this position: rx = -26;ry = -100;and that the perfect green (0, 255, 0) color is at this position: gx = -50;gy = 76. He knows that the perfect blue (0, 0, 255) color is at this position: bx = 62;by = 10; and that white (0, 0, 0) is at this position: wx = 0;wy = 0; and that black
  • #1
metalfred
2
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
  • #2
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.
 
  • #3
Thanks a lot Mark for your help! I reall appreciate ;)

-fred
 

1. How does the triplets to 2d conversion formula work?

The triplets to 2d conversion formula is a mathematical equation that takes three numbers (triplets) as input and converts them into two dimensions. It is based on the Pythagorean theorem and uses trigonometric functions to determine the coordinates in the x and y axes.

2. Why is the triplets to 2d conversion formula useful?

The triplets to 2d conversion formula is useful in various fields such as computer graphics, image processing, and data visualization. It allows for the representation of three-dimensional data in a two-dimensional space, making it easier to understand and analyze.

3. Are there any limitations to the triplets to 2d conversion formula?

Yes, the triplets to 2d conversion formula has limitations. It can only convert three numbers to two dimensions, so it is not suitable for converting higher dimensional data. Additionally, it assumes that the triplets represent points in a 3D space, so it may not work for other types of data.

4. Can the triplets to 2d conversion formula be reversed?

Yes, the triplets to 2d conversion formula can be reversed. By using the inverse trigonometric functions, the formula can be modified to convert two-dimensional coordinates back to three-dimensional triplets. However, there may be some loss of information in the conversion process.

5. How accurate is the triplets to 2d conversion formula?

The accuracy of the triplets to 2d conversion formula depends on the precision of the input numbers and the implementation of the formula. In most cases, it provides a close approximation of the original data, but it may not be completely accurate due to rounding errors and other factors.

Similar threads

Replies
24
Views
1K
Replies
49
Views
1K
  • Mechanical Engineering
Replies
5
Views
866
  • Calculus and Beyond Homework Help
Replies
7
Views
1K
Replies
7
Views
1K
  • Special and General Relativity
Replies
6
Views
1K
  • Introductory Physics Homework Help
Replies
4
Views
1K
  • Precalculus Mathematics Homework Help
Replies
13
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Replies
1
Views
817
Back
Top