4 Replies - 349 Views - Last Post: 01 November 2015 - 07:41 PM
Posted 30 October 2015 - 07:56 AM
Replies To: Image processing.
Re: Image processing.
Posted 30 October 2015 - 11:58 AM
If the range for each color is 0 to 1 then that's 0% to 100% of that color and there is nothing that can be outside of that range. There's nothing more than having all of that light color and nothing less than having none of that color light. (RGB being red, green, and blue. The A of course is alpha transparency.)
I've seen color done this way a lot in game programming. And I think they almost always use floats to store those numbers between 0 and 1 which means much of what a float is capable of storing is wasted.
It's been a very long time since I had to study floating point numbers in school. But I believe that they are extremely good at storing almost infinitesimaly small numbers. So, you probably gain back a lot of what you lost by the ability to store an enormous range of values between 0 and 1. I believe you get 23 bits of actual numbers with a 32 bit float. So, that should be well over 8 million precise decimal values between 0 and 1. Eight million degrees of change in brightness of a color is a lot and far more than the human eye can detect.
But using a float will allow you to store negative values even if they are out of range or do not make sense. Most of the numbers I see in computer graphics, even on the graphics card itself are stored as floats. I think all the registers, or most anyway, in the graphics card must be of float data type. We use float for pretty much everything. It's almost as popular as using Int most other places.
Anyway, I'm guessing it has to do with the way things are stored internally as floats instead of unsigned data types.
I also never really understood why they do a percentage between 0 and 1 instead of just a 32 bit unsigned integer to represent the color range of that color. but if I'm working in HLSL it's inevitably 32 bit signed floats usually together in some form of tuplet. And even so, it's usually color values between 0 and 1 in those floats. If you go over 1 it's considered 1 still because it's 100%. So, adding two lights together can never add up to more than 100%. So, if I add 30% blue light to 75% blue light it's 100% blue light, not 105% blue light because there is no such thing. This is why it's very easy to wash colors out to white. When all 3 color values exceed 100% they are then all at 100% and the result is white light.
If you add a color like red, green, blue .22,.22,.85 (which is a fairly light blue) to .80, .80, .80 ( a very light gray) it's going to add up to 1,1,1 which is white because none of the numbers can exceed 1. So, it's very easy to wash colors out to white when adding them.
This post has been edited by BBeck: 30 October 2015 - 12:28 PM
Re: Image processing.
Posted 01 November 2015 - 07:41 PM
Green hue is at 90 degrees, or equivalently -270 degrees. Using floats allows for code reuse for multiple color systems in OPENCV.
This post has been edited by jjl: 01 November 2015 - 07:45 PM