Bit Depth of Raw Converter

Moderator: jsachs

jsachs
Posts: 4203
Joined: January 22nd, 2009, 11:03 pm

Re: Bit Depth of Raw Converter

Post by jsachs »

If you email me a small (roughly 400x400 pixel) section of a converted raw file saved as a 48-bit TIFF I can check it with Count Colors here.

jsachs@dl-c.com
Jonathan Sachs
Digital Light & Color
Charles2
Posts: 225
Joined: November 24th, 2009, 2:00 am
What is the make/model of your primary camera?: Fuji X-Pro 2
Contact:

Examination of shot with lens cap on

Post by Charles2 »

Took a shot with the lens cap on, shutter set to 1/500 second. Ran the DNG file through PWP Raw Converter 5.0.1.9 with no changes. Sampled random pixels with Readout tool set per Dieter (1 x 1 that is, single pixel read, RGB values in decimal).

There were many triples 0,0,0, perhaps half of the dozen or two sampled. The other triples were typically like these:
1151,0,0
0,0,1727
1207,1207,1207
3158,0,698
0,0,581
2105,0,424
The only value I found less than 256 was 0.

I opened the same image in Raw Therapee, using EAHD raw conversion. The readout in this program is only 8 bits, and all the triples I sampled were 0,0,0. I don't know whether Raw Therapee smooths the data or whether PWP generates variation in the data.

Zoomed to 1:1, the image remains solid black to my eye on an S-IPS monitor that claims the usual 16.7 million colors, that is, 8-bit depth x three channels. Perhaps the image would look different on an Eizo or other monitor that displays more bits, but I wonder whether my eye could see a difference.

Then I applied Levels | Full Range (HSL). The result was a riot of noise as shown in this crop shown at 100%. PWP said the range before the transform was 0.0% to 5.1%, so Full Range expands almost 20 times, an obviously artificial result.

Image

Is it correct to conclude that sensor noise and the Bayer filter loss (combining adjacent R, G, and B values into the color of one pixel) overwhelm attempts to get a 16-bit "true" capture of a scene? The advantage of post-processing in 16 bits is that it minimizes further distortion from rounding ("software noise") while we tweak the scene from what the camera saw to what we think should be presented.
jsachs
Posts: 4203
Joined: January 22nd, 2009, 11:03 pm

Re: Bit Depth of Raw Converter

Post by jsachs »

This is not a good test since the gamma curve that must be applied to the linear raw data is very steep near 0 (black), so large steps are to be expected. A better test might be a blue sky or a white wall exposed so that it does not max out any of the channels but where the variations should be very subtle. Then you should see small variations in the individual channels for the image. If you email me part of a normal image I can give you a definitive answer.
Jonathan Sachs
Digital Light & Color
Robert Schleif
Posts: 340
Joined: May 1st, 2009, 8:28 pm

Re: Bit Depth of Raw Converter

Post by Robert Schleif »

Despite the image I am converting (some generated by variations of that above) or the setting on dynamic range in the converter, I still cannot get the raw converter to generate 16 bit files with any more than a handful of pixels with r, g, or b values greater than zero and less than 256. I'd like to be able to work with images that my camera must be recording as having greater dynamic ranges than 256, but the converter seems reluctant to assign values other than zero or above 256.
For example, if an area of a converted image has r, g, b values in the range of 1,000 to 15,000 as measured by the readout tool, when I move the left-hand slider of the dynamic range control further to the left and convert again, the same area of the converted image now has values of 0, 0, 0. They should be more like 20 upwards. It seems to me that the converter rounds most everything darker than 256 to zero, then places the result in the top 8 bits of a 16 bit file. This is not what I would want or expect in a full 16-bit work flow.
ksinkel
Posts: 594
Joined: April 2nd, 2009, 11:58 am
Contact:

Re: Bit Depth of Raw Converter

Post by ksinkel »

In a 16 bit workflow, the highest level is 65535. 256 is just under 0.4% of the total range. To place this number into perspective, consider a fifteen step grayscale target. The two darkest levels, which are barely distinguishable from each other, have values of 0 and 4600. Thus a level of 256 in a 16 bit image just a fraction of this barely distinguishable step -- i.e. the eye cannot distinguish it from black.

The principle advantage of 16 bit images is not in the first 256 levels. If we compare 16 bits to 8 bits, the advantage is that 16 bit images have an extra 256 levels between every pair of 8 bit levels. This avoids round-off errors and makes the image much more robust in the face of manipulation. If you want to see a dramatic example of this take an 8 bit image with a smooth full-scale histogram and compress the dynamic range with the Levels and Color transformation to, say 75%.Click OK and then use the same transformation to expand the range again. When you examine the histogram you will see that the histogram is no longer smooth but is a series of spikes. This is because once two levels are compressed into one they cannot be distinguished any longer -- information has been lost. A sixteen bit image gives you a 256x advantage against that happening.

Kiril
Kiril Sinkel
Digital Light & Color
jsachs
Posts: 4203
Joined: January 22nd, 2009, 11:03 pm

Re: Bit Depth of Raw Converter

Post by jsachs »

Camera sensors capture linear images (gamma 1.0). The raw converter needs to apply a gamma correction curve to the raw data. This curve is extremely steep between 0 and 256 so it is normal to not see values between 0 and 256 in the converted 16-bit image. The curve is much less steep at the high end so the converted levels will be much closer together there. The real test is how many colors are in one of the channels in an image that coverts more or less the entire dynamic range. The recently uploaded version of PWP can do this calculation.
Jonathan Sachs
Digital Light & Color
Dieter Mayr
Posts: 453
Joined: April 24th, 2009, 11:47 am
What is the make/model of your primary camera?: Nikon D700
Location: Salzburg / Austria

Re: Bit Depth of Raw Converter

Post by Dieter Mayr »

I have tested the image i have made the measurements before with Jonathans method of counting the colors in a RGB channel and for all 3 channels I have color counts in the 65000 range.
So it is definately 48 bit.
As said before, it is a RAF file from a Fuji S3.
Dieter Mayr
Robert Schleif
Posts: 340
Joined: May 1st, 2009, 8:28 pm

Re: Bit Depth of Raw Converter

Post by Robert Schleif »

Yes, 16 bits provides more levels of intensity and this reduces posterization of dark areas, and yes, there is no question that 16 bits are being used in PWP to describe intensities above the value of 1/256. This is seen by the facts that a. the count colors tool yields numbers above 60,000 and, and b. the darken and lighten transforms described at the beginning of this thread work as expected. Nonetheless if, for example, the lowest intensities, that is, intensities below 1/256 of the brightest were rounded to zero as the 16 bit file was being written, then the maximum number of intensities that could be measured would be 65,535 - 255 = 65,280. Therefore, only if count intensities yields numbers exceeding 65,280 does it show that low intensities, those below 1/256 are being properly recorded. So far, I've not been able to convince myself that they are.

I am interested in the answer because some scenes I shoot are of high contrast with the darker regions less than 1/256 as intense as the bright regions. Since my camera records these scenes with 12 bits of intensity information, I'd like to be able to work with these darker regions to make the best possible representation of the scene as I perceived it. To do this I'd like to know how my camera and the raw converter are handling these low intensity regions.

To ask my question explicitly and most generally, suppose that I have a raw file showing 16 squares of different intensity. I would like to know what the intensities would be after the PWP raw conversion (ignore complications introduced by the Bayer conversion). Let the 16 different intensities be: 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, and 32768. My experimentation thus far suggests that the predominant resulting intensities will be 0, 0, 0, 0, 0, 0, 0, 0, 256, 512, 1024, 2048, 4096, 8192, 16384, and 32768.

The comments in an earlier reply about perception of minor gray differences are certainly correct. In printing, the maximum difference in reflectance between black and white is less than 100. Thus, even in printing 8 bit images one must make some intensity adjustments so make things look good. In real HDR, one tries to capture a very broad range of intensities, and then one compresses and expands different tonality regions so as to create the effect one wants, which often is an image that feels much our visual system perceived the scene. I'd expect to have to compress and expand so as to make best use of 12 bits worth of intensity information in an image. By the way, in real HDR, multiple images are used to generate a very broad range of intensity, and then the tonality must be compressed and manipulated to as to yield a pleasing image.
jsachs
Posts: 4203
Joined: January 22nd, 2009, 11:03 pm

Re: Bit Depth of Raw Converter

Post by jsachs »

I have explained this twice already, but maybe I have not been clear enough. Camera sensors have a linear response since they measure in effect photons per second arriving at each pixel location. The eye does not respond linearly - it is much more sensitive to small changes in dark values that to light values as measured on a linear brightness scale. To convert from camera data to a color space that is appears to the eye to have uniform steps in brightness you apply a gamma curve - typically around gamma 2.2 which models the eye's sensitivity. This curve is vertical at 0% and has a slope of less than 45 degrees at 100%, so it introduces big steps in very low brightness levels which is what you are seeing. This does not mean there is anything wrong with your camera or that it is not capturing 12 bits of data.
Jonathan Sachs
Digital Light & Color
Robert Schleif
Posts: 340
Joined: May 1st, 2009, 8:28 pm

Re: Bit Depth of Raw Converter

Post by Robert Schleif »

A am sorry, I had a misunderstanding of the way gamma is used in the conversion from raw. I believe the following is essentially correct.
What is stored in the pixels of the raw file is directly proportional to the exposure, but upon conversion to a 16 bit tif file, the pixel values are related to the value in the raw file by the relation
Value = 65536 x Exposure^(1/gamma) where ^ means exponentiation, and an Exposure of 1.0 is that exposure which is just sufficient to give the maximum pixel value without saturation.
Equivalently, Log (Value) = Log(65536) + (1/gamma) x Log (Exposure)
Normally, a gamma of 2.2 is used.
In the raw file produced by a camera with a 12 bit analog to digital converter, the lowest or darkest nonzero pixel value would be 1/(2^12) = 1/4096 of the brightest. When converted to a tiff file using a gamma of 2.2, the luminosity value of such a pixel would be:
Value = 65536 x (1/4096)^(1/2.2) = 1495 .
Thus, in the tif files resulting from conversion from a 12 bit depth raw file using normal raw converter settings, there should be found values of 0, and from 1495 upwards to 65536, but none between 0 and 1495. Similarly, for raw files from cameras with 14 and 16 bit analog to digital converters, the minimum nonzero values are 795 and 424 respectively.
With respect to my camera and to PWP’s raw converter, I am happy to report that both are working properly as expected.
Post Reply