color.js icon indicating copy to clipboard operation
color.js copied to clipboard

Output as RGBW for driving multicolor LEDs.

Open ChristianMayer opened this issue 4 years ago • 9 comments

For home automation purposes it would be great to have the possibility to convert a color not only to R, G and B but also to a red, green, blue and white component. Probably even to two different whites at the same time where each white has a different temperature.

(For the R, G, and B the wave lengths and/or exact colors should be adjustable)

ChristianMayer avatar Feb 07 '21 12:02 ChristianMayer

I'm not familiar with this color space, not sure if @svgeesus is. Could you provide any more information about it?

LeaVerou avatar Feb 08 '21 12:02 LeaVerou

It's not really a color space: this is for home / building automation purposes where you have colored LEDs or LED strips. Many of those don't only contain a red, green and blue LED, but also a white one as producing white by 100% R, G and B isn't as bright as needed for room lighting purposes as well as it's CRI is bad and getting the mixture right for an intended color temperature is nearly impossible at the home automation level (no calibration and the curves are depending on device specifics that are mostly unknown).

Some LEDs even have two white channels, each with a different color temperature. This allows human centric lighting (HCL) where the color temperature in the room mimics the color temperature of the sun.

I'd like to use color.js at the @CometVisu to convert colors between the visualization where user controls the settings and the output to the LED actors.

So the task is similar to generate the K channel of the CYMK color space used for printers. But as I'm "printing" with light I need the W channel of RGBW. :)

ChristianMayer avatar Feb 08 '21 22:02 ChristianMayer

The problem is that you want to output the intensities of LEDs, which mix to create a color. But you don't know:

  • the transfer function (relationship between signal intensity, which is typically PWM ratio for driving multicolor LEDS, and output light intensity
  • the chromaticity of the color produced by each LED.

Without that colorimetric basis, it is not possible to convert from a color to LED signal levels.

You would need measuring equipment - a light meter, and a spectrophotometer, to measure the intensity produced by each LED at each wavelength (and measure that, at various intensities).

svgeesus avatar Feb 09 '21 13:02 svgeesus

@ChristianMayer Do note that conversion of a color to CMYK is similarly not straightforward, it depends on which CMYK space you'd be converting to, there are hundreds of CMYK spaces, based on inks, paper type etc. You may find math on the Web about generally "converting RGB from/to CMYK" but those have no actual meaning, e.g. they produce CMYK colors that cannot be printed by any printer (such as sRGB #0FF). I wonder if the LED strips you're working with may have some information about what color space they produce, or even what absolute color values their primaries are in (the color space can then be calculated).

LeaVerou avatar Feb 09 '21 14:02 LeaVerou

Taking one example of a LED strip from a well known manufacturer I find this specification: https://dammedia.osram.info/media/resource/hires/osram-dam-15999374/LINEARlight%20Flex%20Colormix%20RGBW%20V2.pdf There you can see that the color temperature of the white LED is depending on the product type (you can get e.g. 2700 K) with a maximum (= 100% PWM) of 697 lm/m. The red has a wave length of 622 nm with a 100% intensity of 80 lm/m, the green 534 nm with 196 lm/m and the blue 468 nm with 21 lm/m. The dimming curve is depending on the LED driver. Very common is a logarithmic transfer curve but there are also drivers that can be set up to be linear or logarithmic or even some obscure custom mode.

In the perfect world I'd expect a user to use a spectrometer and get a full profile in a ICC file. Then it would be straight forward (at least in the RGB case) to convert an sRGB value to the LED driver settings. There's no difference to a computer screen here.

But in a real word application the most common use case would be to input the R, G and B wave lengths, the maximal intensities and the shape of the transfer curve (and in the RGBW case the color temperature of the white LED). This should be good enough for 99% of all cases and I guess no one would complain that the room lighting is > 3 DeltaE from the intended value chosen on the computer display.

ChristianMayer avatar Feb 09 '21 15:02 ChristianMayer

The red has a wave length of 622 nm with a 100% intensity of 80 lm/m, the green 534 nm with 196 lm/m and the blue 468 nm with 21 lm/m.

Thanks for providing the data sheet. Those are dominant (i.e. peak) wavelengths. These are not single-wavelength sources. So that is not enough info to calculate the colorimetry. They would need to be measured at all wavelengths, to calculate that.

In the perfect world I'd expect a user to use a spectrometer and get a full profile in a ICC file.

No, you would probably (unless they are very non-linear) not need to make multiple measurements like with CMYK. You would just need the full spectrum, from which can be calculated the CIE XYZ value.

svgeesus avatar Feb 15 '21 18:02 svgeesus

RGB LED spectra

Example RGB LED spectra. Calculating CIE XYZ requires knowing the value at all wavelengths (sampled at least every 10nm) then multiplying by the three XYZ weighting functions and lastly doing a numerical integration to get the area under each of the three curves.

svgeesus avatar Feb 15 '21 18:02 svgeesus

The wikipedia article that is showing graph is stating

FWHM spectral bandwidth is approximately 24–27 nm for all three colors.

According to Nyquist the 10 nm measurement step width is just enough to measure these peaks. So for real world lighting applications it's sufficient to assume that the LED is monochromatic.

A high sophisticated user might want to use measured xy-coordinates instead of the wave length. But an ordinary user would just use the wave lengths from the specification instead (and by that neglecting aging as well).

ChristianMayer avatar Feb 15 '21 18:02 ChristianMayer

Seems that it is not quite that simple

svgeesus avatar Feb 17 '21 03:02 svgeesus