Olympus-OM
[Top] [All Lists]

[OM] If you think all bits are created equal for image storage, you need

Subject: [OM] If you think all bits are created equal for image storage, you need to read this, even though it is long. [was RAW Bit Depth]
From: Moose <olymoose@xxxxxxxxx>
Date: Sat, 07 Apr 2007 21:10:22 -0700
Winsor Crosby wrote:
> I just recently discovered that the Leica M8 RAW file has a bit depth  
> of only 8 bits unlike the 12 to 14 other makers have. Doesn't that  
> just about kill the main advantage of RAW over a very high quality  
> JPEG format, or TIFF?
>   
You are drawing a parallel that is not necessarily accurate, and almost 
certainly not accurate in this case. To explain why, I need to talk 
about a few things.
----------------------------------------------------------------

I.  There are limitations to the meaning of distinctions between values 
in any measurement system.

Resolution is the minimum difference in measured value that a 
measurement system can distinguish.

Accuracy is the measure of how close a value determined by the 
measurement system is to the true value.

For example, I might have a scale with a resolution of 0.1 ounce and an 
accuracy of ± 0.1 ounce. Then the value read may be higher or lower than 
indicated, so to be sure a letter is not over 1 ounce, I must be sure it 
doesn't measure more than 0.9 oz.

Between them, resolution and accuracy determine how much data detail is 
meaningful from any measuring system.
----------------------------------------------------------------

II.  Storing nonlinear data in linear number spaces has interesting 
resolution consequences.

If you take the analog output from a linear device, such as a camera 
sensor, through a linear A to D converter you end up with an interesting 
situation. Because of the way the human vision system works, the steps 
of brightness used in photography, f-stops and EVs, involve 
doubling/halving the light for each stop.

So, in an 8 bit range of brightness, the last stop is the range from 
129-256, the next lower stop is from 65-128:

1 - 129 - 256 = 128 steps
2 -  65 - 128 =  64 steps
3 -  33 -  64 =  32 steps
4 -  17 -  32 =  16 steps
5 -   9 -  16 =   8 steps
6 -   5 -   8 =   4 steps
7 -   3 -   4 =   2 steps
8 -   1 -   2 =   1 step

So in an image file like JPEG, although it can contain about 8 stops of 
brightness data, there is very little resolution within the lower stops 
and more than may be necessary in the upper ones.
----------------------------------------------------------------

III.  With that background, we can look at alternate ways to map linear 
data from a sensor system into a digital image file without losing tonal 
resolution.

1. One way is simply to map 12 bit output from the sensor system into 
the top part of a 16 bit storage scheme. That way, the range from the 
lowest light level that can be captured to twice that level has lots of 
numerical resolution available. I believe this is why converting 8 bit 
data to 16 bit in an image editor before manipulating the image has so 
much better results than working in 8 bit.

2. Another way is to change the mapping from linear. Let's assume that 
the R&R characteristics of an imaging system are such that 32 meaningful 
brightness steps may be derived for each doubling of brightness. Then 
the range of values from 129 to 256 can contain not one, but 4 stops 
worth of information:

1 - 129 - 256 = 128 steps = 4 stops
2 -  65 - 128 =  64 steps = 2 stops
3 -  33 -  64 =  32 steps = 1 stop
4 -  17 -  32 =  16 steps = 1/2  stop
5 -   9 -  16 =   8 steps = 1/4  stop
6 -   5 -   8 =   4 steps = 1/8  stop
7 -   3 -   4 =   2 steps = 1/16 stop
8 -   1 -   2 =   1 step  = 1/32  stop

This design allow storage of 8 stops of data, with 32 steps within each 
stop, in one byte of data, with the first nibble holding one stop and 
the top one holding 7 stops.
----------------------------------------------------------------

I'm just illustrating a principle here, not proposing that exactly this 
theoretical construct is used by anybody. I do hope it makes it clear 
why 8 bits in a linear storage system like JPEG and TIFF may be vastly 
different from a nonlinear mapping storage design.

I also know that lossless schemes for minimizing data storage size have 
been around since at lest the dawn of computing. Even a hack like me has 
compressed 8 one bit channels into one byte, rather than the 8 bytes 
conventional data types would use, then uncompressing for display.

I have no real idea of the tonal resolution and accuracy limits of these 
systems, although I can guess that commercial designs won't go beyond 
about twice the similar figures for the human vision system. I have also 
simplified and idealized the example, leaving out noise and signal 
processing effects and probably other factors I don't even know about.

If the R&R limit is 16 steps, a byte could hold 16 stops, 24 steps, 
almost 11 stops, and so on. Noting that the highest measurable range of 
any DSLR tested by dpreview so far is almost 8.5 stops, and adding fudge 
factors for other issues, I suspect a 24 step per stop design would 
easily handle all the real data available from the sensor system. 
Although I'm too lazy, in this theoretical discussion, to look for the 
brightness resolution limits of human vision, I'll bet it's 
significantly less than that.
----------------------------------------------------------------

It's easy enough to imagine how a designer could do such a mapping into 
a proprietary RAW format and put the unmapping algorithm into the SDK 
used by RAW converter programmers to unpack the RAW file, but how does 
that work with the DNG format used by Leica? To quote from the DNG spec:

"LinearizationTable describes a lookup table that maps stored values 
into linear values....."

"Mapping Raw Values to Linear Reference Values

This section describes DNG's processing model for mapping stored raw 
sensor values into
linear reference values......

Linearization
The first step is to process the raw values through the look-up table 
specified by the
LinearizationTable tag, if any."

There are other details, but you see that DNG provides the facility to 
do exactly what I outline above.
----------------------------------------------------------------

So yes, Winsor, there is a Santa Claus, and it is possible to store 9 or 
more stops of detailed tonal range into 8 bits. But when remapped into a 
linear storage scheme, more than 8 bits are needed for the output to 
avoid loss of tonal detail. Convert to 16 bit TIFF.

Moose

Further speculations for those still with me:

The large disparity in file sizes and the difference in bit depth 
between the E-1 and contemporary C models may well be because C had the 
time, money and processor power to do something like the above in 
camera, while Oly simply added a couple of bits to the bottom of an 
essentially 8-9 stop system to maintain tonal resolution at the low end 
and wrote it out.

The same thing probably explains the large RAW File sizes in those few 
digicams that have RAW.

Moose

==============================================
List usage info:     http://www.zuikoholic.com
List nannies:        olympusadmin@xxxxxxxxxx
==============================================

<Prev in Thread] Current Thread [Next in Thread>
Sponsored by Tako
Impressum | Datenschutz