Need the easiest way to convert HSI to RGB (integer)
![Bean](https://forums.parallax.com/uploads/userpics/855/n505WZVEIPHT1.jpg)
Is the an easy way to convert HSI (Hue, Saturation, Intensity) to RGB (Red, Green, Blue) with integer math ?
Both the HSI values and the RGB values will be in the range [noparse][[/noparse]0..255].
I've found several formulas on the web, but none seem to work properly. Or maybe it's me...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Teacher: What is the difference between ignorance and apathy ?
Student: I don't know and I don't care
Teacher: Correct !
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
Both the HSI values and the RGB values will be in the range [noparse][[/noparse]0..255].
I've found several formulas on the web, but none seem to work properly. Or maybe it's me...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Teacher: What is the difference between ignorance and apathy ?
Student: I don't know and I don't care
Teacher: Correct !
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
Comments
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Yesterday is history, tomorrow is a mystery, and today is a gift.
That is why they call it the present.
Don't have VGA?
Newzed@aol.com
·
Jeff T.
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Yesterday is history, tomorrow is a mystery, and today is a gift.
That is why they call it the present.
Don't have VGA?
Newzed@aol.com
·
Where all the forumlas seem to fail is that when I is at the max, R, G and B should be at their max regardless of the H or S value.
And some values produce negative R, G or B answers.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Teacher: What is the difference between ignorance and apathy ?
Student: I don't know and I don't care
Teacher: Correct !
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
There are limitations to the colors that can be represented by RGB. As an example, pure colors, such as those in a rainbow can not be generated by combinations of red, green and blue colors. You would need negative values to generate the true colors of a rainbow.
Even colors that can be generated are limited in one color space versus another. If the luminance is 255, then the RGB values are all 255 as well. It is not possible to represent any color other than white at a luminance of 255. Therefore, saturated colors cannot be represented when the luma is high.
Saturated colors can be represented when the luma is low. However, if the saturation is artificially increased at low luma values it could result in negative RGB values.
The 8-bit values may be overflowing if you are getting negative RGB values when the intensity is high. You could clip the values to 255, but the colors will not be correct.
Dave