4 Replies - 504 Views - Last Post: 01 November 2015 - 07:41 PM

#1 Zibele  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 29
  • Joined: 18-September 15

Image processing.

Posted 30 October 2015 - 07:56 AM

I'm just a bit curious,i have been studying opencv for a while now.So i recently just read up on changing brightness,lets say i want to decrease brightness and the value i am decreasing the pixel by exceeds the value of the original pixel,so instead of the new altered pixel going into negative values ,it instead goes to zero(according to the source).So why would it be a necessary to specify signed or unsigned depth if it only supports unsigned values?

Is This A Good Question/Topic? 0
  • +

Replies To: Image processing.

#2 Ruben_  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 7
  • Joined: 08-October 15

Re: Image processing.

Posted 30 October 2015 - 09:03 AM

My first guess would be that with a signed depth you're able to redo the action

(without data loss)
Was This Post Helpful? 1
  • +
  • -

#3 BBeck  Icon User is offline

  • Here to help.
  • member icon


Reputation: 760
  • View blog
  • Posts: 1,818
  • Joined: 24-April 12

Re: Image processing.

Posted 30 October 2015 - 11:58 AM

I'm just going to make a semi-educated guess and say that they may be doing RGBA color with 32 bit float values. Although it sounds like they are doing them in percentages rather than absolute values.

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

Was This Post Helpful? 0
  • +
  • -

#4 Zibele  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 29
  • Joined: 18-September 15

Re: Image processing.

Posted 31 October 2015 - 02:55 AM

Thanks for the reply guys :)
Was This Post Helpful? 0
  • +
  • -

#5 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,769
  • Joined: 09-June 09

Re: Image processing.

Posted 01 November 2015 - 07:41 PM

OpenCV, like most libraries, try to maximize code reuse. Of course, the RGB or mono channel color range is unsigned, but that isn't true for all color systems. HSV for example, which bases its HUE on an angle, which can be positive or negitive.


i.e.
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

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1