Converting RGBC from Flora to HSV color wheel

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
jjthomson2
 
Posts: 5
Joined: Mon Nov 25, 2013 7:19 pm

Converting RGBC from Flora to HSV color wheel

Post by jjthomson2 »

Hi. I am interested in converting the RGB + C outputs from the Flora sensor to points on the HSV color wheel. To do that, I need normalized RGB plus a "value", which is dependent on the total amount of light returned. The value is just the max of RGB. I understand that the normalized value is supposed to be given by dividing R, G, or B by C, but when I simply do this, it does not correspond to the colors it should on the wheel. For example, a white is given by .375, .38, .24. This actually comes out very grey. This suggests that the max of RGB is about 3 times too low. In another case, 2 reds come out the same, even though one has obviously more saturation value than the other. Is there something I am missing that perhaps has to do with the absolute value of C? Thanks for any help.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Converting RGBC from Flora to HSV color wheel

Post by adafruit_support_mike »

The numbers used in NeoPixel colors are PWM duty cycles rather than RGB color values. To convert from duty cycle to RGB, you need to account for the way the human eye handles light.

We don't see absolute light levels. We see ratios. "Twice as many photons" looks like the same change in intensity whether it's a change from 1 photon to 2, or 1,000,000 to 2,000,000 (and we do see both those ranges).

The conversion function you'd need is something like:

Code: Select all

uint8_t rgbR = ln( pwmR ) * 46;
uint8_t rgbG = ln( pwmG ) * 46;
uint8_t rgbB = ln( pwmB ) * 46;

jjthomson2
 
Posts: 5
Joined: Mon Nov 25, 2013 7:19 pm

Re: Converting RGBC from Flora to HSV color wheel

Post by jjthomson2 »

I'm not sure what NeoPixel is. I am trying to convert the output from the Flora TCS34725 output to the Arduino to normalized rgb values to use in the HSV color wheel. Your answer is not right for me - it converts all the output signals to white. Jeff

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Converting RGBC from Flora to HSV color wheel

Post by adafruit_support_mike »

My mistake.. I was thinking about output rather than input.

When you calculate a normalized RGB value, what's the maximum value any of the components can have?

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Converting RGBC from Flora to HSV color wheel

Post by adafruit_support_bill »

The sensor is giving you absolute values that will be proportional to the overall illumination of the target object. Lowering the illumination does not change the color of the object, but the R, G, B and C values reported will be lower across the board. You can calculate H & S from the R, G and B, but the C does not necessarily map directly in to the V. You would need to calibrate your sensor against a reference gray scale under the same illumination conditions.

jjthomson2
 
Posts: 5
Joined: Mon Nov 25, 2013 7:19 pm

Re: Converting RGBC from Flora to HSV color wheel

Post by jjthomson2 »

Thanks for your answers. The max value is 1. I think the last poster is right. As I remember, the Flora sensor has an onboard LED of about 4000 degrees. This is strongly biased toward the red. It would be better to have a 6500 degree LED to get truer colors. I will probably make one like this. I have an external LED that has the proper color temperature. At the moment, using the Flora, I am trying to calibrate as you suggest. With a pretty white target at a certain distance, I can find readings for r,g,b. I can normalize them to 1,1,1 by dividing by the observed values for white, although I am not sure I should do this for the blue sensor, since the color temperature is low, biasing away from blue as it is.
From the absolute values, if they are accurate, I can get the value from the observed readings: V=max(r,g,b) after normalization.
Jeff

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”