Ask Your Question
0

Why pixels can have float values?

asked 2016-01-13 10:01:17 -0500

Gren8 gravatar image

Hello,

This may be a simple question, but i wonder why pixel values can have float values? I'm tracking a target and get the mass center with contours() and moments() method and if i want i can get float values of them.

But why is this even possible? An image can't have a 0.1234 Pixel. Can anybody explain this to me please?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
6

answered 2016-01-13 10:55:45 -0500

kbarni gravatar image

updated 2016-01-14 03:40:43 -0500

Using 255 shades for pixels is only a concept. It was introduced because byte values are easy to store and access, and use little space in memory.

Sometimes it's too much (binary images) and sometimes this is not enough: professional cameras often use 10-14 bits (1024-4096 shades) to store color information. So the value of white is device-dependent.

To cope with this arbitrary maximum, it's already a good idea to use floating-point values. 0 means black, 1 means white, and 0.1234 is always ~12% grey.

In image processing, pixel values can mean other things than grey values, too: probabilities (e.g. to have an object at the given position), normalized vectors, derivatives, etc, which are all non-integer values. Some formulas need normalized values between 0 and 1 as input values. Some formulas even result complex numbers (like the Fourier transform).

The only thing to remember is that displaying needs values between 0..255, so finally you'll have to normalize the image (look for the min/max values, multiply every pixel with 255/(max-min) and take the integer part)

Furthermore, non-integer pixel coordinates are also justified sometimes. For example, when you zoom an image by 20%, every coordinate will be:

x' = x*1.2
y' = y*1.2

which are non-integer values. The fractional part is important for interpolation: for example the pixel at coordinate x=1.2 will be interpolated as 80% pixel x=1 and 20% the pixel x=2.

edit flag offensive delete link more

Comments

Btw, I forgot another important aspect of fractional pixel coordinates: like the colors, the image coordinates can be normalized between 0...1 (or -1...1): like this the operations become resolution and scale-independent.

In texturing applications (OpenGL) this convention is used a lot.

kbarni gravatar imagekbarni ( 2016-01-15 08:39:15 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-01-13 10:01:17 -0500

Seen: 911 times

Last updated: Jan 14 '16