Convert Lux to RGB: 4 Values to RGB/Hex Color

  • Thread starter Thread starter noknow
  • Start date Start date
  • Tags Tags
    Convert Lux
Click For Summary
SUMMARY

The discussion centers on converting optical sensor outputs in lux format, specifically [Red, Green, Blue, IR], into standard RGB (0-255) or hex color values for display on a PC. Participants emphasize the importance of scaling the sensor's output voltage to ensure optimal dynamic range without clipping. They suggest utilizing false color algorithms to represent IR values visually and recommend researching JavaScript libraries for real-time YUV to RGB conversion. Key resources include a formula link for RGB to lux conversion and insights into luminosity and color perception.

PREREQUISITES
  • Understanding of RGB color model and its representation (0-255)
  • Familiarity with optical sensors and their output formats
  • Basic knowledge of colorimetry and human spectral response
  • Experience with JavaScript for web development
NEXT STEPS
  • Research the formula for converting RGB to lux and vice versa
  • Explore false color rendering techniques for displaying IR values
  • Learn about JavaScript libraries for YUV to RGB conversion
  • Investigate the impact of sensor voltage scaling on RGB output
USEFUL FOR

Web developers, optical sensor engineers, and anyone interested in color conversion techniques for digital displays.

noknow
Messages
5
Reaction score
1
I have an optical sensor that outputs 4 values in the following format: [ Red, Green, Blue, IR] where each value is in lux. I want to take this output and render a color on my pc. I'm not sure how to convert this into a regular RGB (0-255)/hexcolor value. Is there a good place to start? The data sheet I have on the device doesn't mention anything about a conversion. Many thanks.
 
Last edited:
  • Like
Likes   Reactions: berkeman
Engineering news on Phys.org
noknow said:
The data sheet I have

Can you share?

BoB
 
noknow said:
I have an optical sensor that outputs 4 values in the following format: [ Red, Green, Blue, IR] where each value is in lux. I want to take this output and render a color on my pc. I'm not sure how to convert this into a regular RGB (0-255)/hexcolor value. Is there a good place to start? The data sheet I have on the device doesn't mention anything about a conversion. Many thanks.
I'm not sure that the above link tells the whole story. It may relate to a particular piece of equipment. I would imagine the gains in the four channels of your equipment should take care of things, largely. Your PC will do the usual thing for displaying RGB signals. (0 - 255)
RGB analogue signals will depend on the sensitivity of the sensor. Once you have established (by measurement or from a spec sheet) the peak voltage that the sensor produces then your ADC input just needs to be scaled so that the peak value gives 256 on one of the channels. That will give you the most dynamic range without limiting / clipping.
Lux is a measure of the flux, weighted by the human spectral response curve so the three RGB signals would all be (roughly) equal for incident white light - depending on the colour temperature of the source. The ratios of your RGB readings will, presumably relate to the formula in that link, above.
I don't know about the IR value as we have no perception of those wavelengths. The IR values you get could vary a lot according to the actual spectrum of sources which could 'appear' the same and have equal RGB values. (I'm coming at this from the point of view of TV colourimetry so IR is not part of that.) To display IR as part of your PC image, you would need some false colour algorithm to shift all the colours in the blue direction and make room for IR to be displayed in the Reds. I found a lot of Google hits for False Colour infra red search terms. This could be unnecessary if you are just interested in the long wavelength of the spectrum - you could just feed your monitor with Ir, R , G signals instead of R G B, ignoring the B altogether. Worth trying perhaps; no programming or soldering involved.

PS Astrophotography links will be a rich source of ideas about false colour rendering.
 
Spec sheet for the sensor
sophiecentaur said:
I'm not sure that the above link tells the whole story. It may relate to a particular piece of equipment. I would imagine the gains in the four channels of your equipment should take care of things, largely. Your PC will do the usual thing for displaying RGB signals. (0 - 255)
RGB analogue signals will depend on the sensitivity of the sensor. Once you have established (by measurement or from a spec sheet) the peak voltage that the sensor produces then your ADC input just needs to be scaled so that the peak value gives 256 on one of the channels. That will give you the most dynamic range without limiting / clipping.
Lux is a measure of the flux, weighted by the human spectral response curve so the three RGB signals would all be (roughly) equal for incident white light - depending on the colour temperature of the source. The ratios of your RGB readings will, presumably relate to the formula in that link, above.
I don't know about the IR value as we have no perception of those wavelengths. The IR values you get could vary a lot according to the actual spectrum of sources which could 'appear' the same and have equal RGB values. (I'm coming at this from the point of view of TV colourimetry so IR is not part of that.) To display IR as part of your PC image, you would need some false colour algorithm to shift all the colours in the blue direction and make room for IR to be displayed in the Reds. I found a lot of Google hits for False Colour infra red search terms. This could be unnecessary if you are just interested in the long wavelength of the spectrum - you could just feed your monitor with Ir, R , G signals instead of R G B, ignoring the B altogether. Worth trying perhaps; no programming or soldering involved.

PS Astrophotography links will be a rich source of ideas about false colour rendering.

So my understanding is that lux takes into account the human response/perception of color so I don't need any correction (gamma?) for that. I see that the spec sheet includes min/max counts for RGB but I don't see any max voltage value.
 
noknow said:
lux takes into account the human response/perception of color
Yes. It does its best to achieve that for an 'average' observer. I think including a nonlinear factor would not be possible - can you think of how it could be? You need to read more deeply into what is meant by luminosity. The eye is adaptive so how could you chase that?
noknow said:
but I don't see any max voltage value.

The block diagram implies that the sensor outputs go directly to the ADC. Which Voltage are you referring to?
 
sophiecentaur said:
Yes. It does its best to achieve that for an 'average' observer. I think including a nonlinear factor would not be possible - can you think of how it could be? You need to read more deeply into what is meant by luminosity. The eye is adaptive so how could you chase that?The block diagram implies that the sensor outputs go directly to the ADC. Which Voltage are you referring to?
I will read up on luminosity more, I'm a little lost. I'm not used to viewing data sheets at all and my background is not in EE.
But I'm trying to figure out the next steps given the data sheet.
 
It depends on what you want to achieve. Do you want to produce 'four colour images' with a three colour display' to include IR?
I am still not clear which voltage you refer to as the device appears to produce four digital (8 bit Edit - 16bit) output signals.
 
Last edited:
Having looked at the data sheet I am a bit clearer about what the device does. It will give you RGB values for a particular displayed colour according to (or near) the formula in the link higher up. Afaics, you want to know the RGB values needed to produce a specified colour on the scree in terms of the YUV values?
Formulae for this and the reverse process can be found here. Could that be what you actually need to know?
 
  • #10
sophiecentaur said:
Yes. It does its best to achieve that for an 'average' observer. I think including a nonlinear factor would not be possible - can you think of how it could be? You need to read more deeply into what is meant by luminosity. The eye is adaptive so how could you chase that?The block diagram implies that the sensor outputs go directly to the ADC. Which Voltage are you referring to?
Thank
sophiecentaur said:
Having looked at the data sheet I am a bit clearer about what the device does. It will give you RGB values for a particular displayed colour according to (or near) the formula in the link higher up. Afaics, you want to know the RGB values needed to produce a specified colour on the scree in terms of the YUV values?
Formulae for this and the reverse process can be found here. Could that be what you actually need to know?
I feel like we're getting closer. I want to display the lux values onto my personal site. So it will have to conform to css standards. https://developer.mozilla.org/en-US/docs/Glossary/RGB
RGB are a 3 separate 8 bit integers. Is that enough information?
 
  • #11
Is it as simple as converting a 16 bit value into an 8 bit value?
 
  • #12
noknow said:
Thank
I feel like we're getting closer. I want to display the lux values onto my personal site. So it will have to conform to css standards. https://developer.mozilla.org/en-US/docs/Glossary/RGB
Are you planning to do this manually?

Because I am pretty sure you can find JS plugin libraries that will directly convert YUV to RGB for you on-the-fly.

Here's a Stack Overflow question that should get you started:
https://stackoverflow.com/questions/21264648/javascript-convert-yuv-to-rgb

Alternately, just Google 'JavaScript convert YUV to RGB'.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
Replies
1
Views
8K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 13 ·
Replies
13
Views
13K
  • · Replies 3 ·
Replies
3
Views
2K