Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 ~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), normal 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 FFT).

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 non-integer part is important for interpolation (for example the pixel at coordinate 1.2 (let's note p[1.2]) will be 80% p[1] and 20% p[2].

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), normal 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 FFT).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. sometimes. For example, when you zoom an image by 20%, every coordinate will be:

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

which are non-integer values. The non-integer fractional part is important for interpolation (for interpolation: for example the pixel at coordinate 1.2 (let's note p[1.2]) x=1.2 will be interpolated as 80% p[1] pixel x=1 and 20% p[2].

the pixel x=2.