LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Color-RGB To 100%?

hi all,
The color-RGB functions Resolves the color to "Red Green and Blue"in 255 each, but im working on pait production line so i need to convert these values into 100% (for example 30% Red 60%Blue 10% Green) how to do that?
i know it may seem selly to you, but i have a lack of information in this part of the project?
Majd Badawi
0 Kudos
Message 1 of 8
(5,653 Views)

It just sounds like you have to multiply "255" by your precentage (expressed as a fraction) and then combine the components.

This image show how to apply the same percentage to all three components of a "starting color" to produce a color ramp.

If that does not solve your challenge, post some code and we'll take a closer look.

Ben



Message Edited by Ben on 11-24-2007 08:34 AM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 8
(5,650 Views)
thank you Ben for your interest
well lets say that the problem is like this:
i need to fill 1 litre of the orange color by mixing the three liquid colors Red,Green, and Blue

what is the percentage of each color in this litre? so i could tell the valves to be opened for specified time.

Majd Badawi
0 Kudos
Message 3 of 8
(5,634 Views)
nice example Ben.
Madj, that is exactly what the function vi to RGB is doing: take any color as an input, and decompose it into its RGB conponents. these are U8, therefore to convert to % divide by 255 *100, for each component.
-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 4 of 8
(5,626 Views)
There may be one more step necessary, and that would be to normalize the ratios so that the total equals 100%.  For instance, there is a color orange that is 255, 196, 42 RGB which would equate to 100%,  76.8%, 16.5%.  Sum total would be 193.3333%.  Each percentage should be divided by 1.93333 to get  51.72%,  39.76%, and  8.52%.  So that the sum of these percentages equal 100%.
 
Or more directly with formulas.
 
%R = R / (R + G + B)  * 100%
%G = G / (R + G + B)  * 100%
%B = B / (R + G + B)   * 100%
0 Kudos
Message 5 of 8
(5,616 Views)
yes normalisation would be usefull...Smiley Tongue
-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 6 of 8
(5,591 Views)

Be very careful. The RGB color model works well with light sources, but not with paint (which is a light sink/reflector). This is why printers don't use red, green, and blue inks, but yellow, cyan, and magenta (or some variant thereof). Check out this wikipedia article for a decent overview of the CMYK color model.

0 Kudos
Message 7 of 8
(5,574 Views)
Also check out this article for a RGB to CMYK calculator. The same technique can be applied in LabVIEW. As the wikipedia article states, "the conversions can not be exact" when converting between RGB and CMYK.
0 Kudos
Message 8 of 8
(5,553 Views)