Dynamic range and RAW file "bit depth"

Started Jan 25, 2014 | Questions
GordonBGood Veteran Member • Posts: 6,306
Re: Dynamic range and RAW file "bit depth"
1

completelyrandomstuff wrote:

this is an interesting though. The sensors do not record linearly. There is more data represented in highlights than in the shadows. That's why cameras with higher bit-depth resolve better in the deep shadows.

However, your ideas about the signal from a sensor not generally being linear, as in output of a value whether digital or analogue which varies directly with the intensity of "light flux" striking the sensor per unit area, which is true for all current sensors until they approach saturation of the electron density in the substrate.

The "more codes per stop of light intensity at the bright end is just a natural consequence of digitization of signal and is not an indication of linearity as defined above.  However, it is this surplus of codes in the bright tones of an image that we are not able to see or use that allows us to apply tone response curves to the linear data in order to get better storage efficiency as well as RGB images that we can directly view on our monitors by viewing the recorded colour levels directly.

Regards, GordonBGood

GordonBGood Veteran Member • Posts: 6,306
Re: Dynamic range and RAW file "bit depth"
1

szhorvat wrote:

I found this about linearity. The plots show what you said: it's linear in the shadows and the highlights are compressed. I wonder if this compression is engineered in some way (it would make sense to do it).

The data from your link is does indeed show that the output of sensors is non-linear as it approaches saturation electron density of the sensor substrate, but that is a region that is normally never used in most current digital cameras, which only generally use the sensors in there generally linear range.  A very fiew cameras (such as the Pentax K-5 series) do push the sensor up into this non-linear range for their extended "lower than base ISO sensitivity" range, which works fine especially if raw development then compensates for the non-linear response.

Regards, GordonBGood

GordonBGood Veteran Member • Posts: 6,306
Re: Dynamic range and RAW file "bit depth"
1

completelyrandomstuff wrote:

Two things, digitization is not done linearly. But more importnatly, I think the camera with 77000 electron capacity could have more dynamic range than 16.23EV, for example in case when the last few electrons filling in the well needed more light per electron than the previous ones. I would be surprised if it was a linear relationship, but I am not able to find the relationship between the photon flux and the well filling at a fixed exposure.

In fact, response is linear especially for those darker last few electrons in the darker tones as shown by extrapolating downward in the Measurement of Responsivity chart on page 9.8 of the linked paper.

There is a definition of the Dynamic Range (DR) limit as limited by quantization which is about 0.288 of the size of the LSB step so a maximum DR of about 15.79 stops for a 14 bit raw, but although one can make out details down to that level in a properly dithered processing workflow, it is mostly only interesting statistically.

In the case of the Foveon sensor, even if the full range to an electron well capacity of 77,000 electrons were used, the black read noise (not well separated from the dark current in the above link) is likely several 10's of electrons thus limiting DR to about 10 stops so there wouldn't be any point to preserving the data to a deeper bit depth as one would only be preserving mostly random noise and other undesirable effects.

Regards, GordonBGood

Jack Hogan Veteran Member • Posts: 6,398
Questions

Completelyrandomthoughts, I don't mean to sound condescending but there is a lot of misinformation being put forth in this thread.  This is not the Open forum. Many contributors here (and I am not including myself) have intimate knowledge of how a camera's hardware and processing works. Therefore it is best to phrase speculative statements as questions so that when one gets rebuffed one does not get one's nose put out of joint.  And whoever will read the thread in the future will not walk away more confused than when they started.

completelyrandomstuff wrote:

That would make sense. The nonlinearity will begin the moment there are interactions between the electrons deficiency in the well. It takes more energy to remove an electron from a more negatively charged body. So that 'compression' is not necessarily engineered, I think it's a consequence of physics.

Is this compression typically visible/usable by a photographer?

However, the way you digitize the signal, is engineered.

In what way?  Are you referring to the ADC or processing after it? AFAIK all current DSLR sensors have linear ADCs.

The camera devotes the least digitization levels to lowest signals and that should, in theory compensate for the nonlinearity of the relationship between photon flux and well filling.

I thought all current DSLR ADCs were linear.  With a very few exceptions (like that mentioned by GBG) aren't non-linearities near saturation clipped away by camera designers therefore not getting stored in the Raw data?

This is why DXO reports the S/N ratio at 18% btw. This 18% corresponds to 50% gray.

Does 18% of saturation in the raw data correspond to middle gray in most DSCs?  Wouldn't DxO instead report SNR at 18% because that's more representative of perceived image noise than reporting it at 0.1% or 99%?

hjulenissen Senior Member • Posts: 2,106
Re: Dynamic range and RAW file "bit depth"
1

szhorvat wrote:

Most cameras can record the sensor data with at most 14 bits of resolution. This means that the ratio of the lowest and highest representable values is 2^14.

The dynamic range of a sensor is the ratio between the brightest and dimmest recordable light intensity (or clipping and noise floor). I notice that DxOMark lists several sensors as having a dynamic range larger than 14 EV, e.g. the Nikon D800 has 14.4 EV, which corresponds to a ratio of 2^14.4.

How can they measure a dynamic range higher than the resolution of the sensor readout? If the sensor response is strictly linear, this shouldn't be possible.

So is the answer that the sensor response is not linear? Is this nonlinearity inherent to how the sensor works, or is it a designed feature aimed at increasing the dynamic range?

I'm asking this for my own edification, not because I need the information to accomplish anything.

If you downsample the image (8MP is used in the DXO "print" number), I believe that zero-mean noise tends to average out, and some measure of DR might exceed that of a single sensel.

Which is sort of similar to the print-argument: when you have more spatial resolution than you need, this can be "re-invested" as better "intensity resolution".

-h

bobn2
bobn2 Forum Pro • Posts: 55,355
Re: Dynamic range and RAW file "bit depth"
1

hjulenissen wrote:

szhorvat wrote:

Most cameras can record the sensor data with at most 14 bits of resolution. This means that the ratio of the lowest and highest representable values is 2^14.

The dynamic range of a sensor is the ratio between the brightest and dimmest recordable light intensity (or clipping and noise floor). I notice that DxOMark lists several sensors as having a dynamic range larger than 14 EV, e.g. the Nikon D800 has 14.4 EV, which corresponds to a ratio of 2^14.4.

How can they measure a dynamic range higher than the resolution of the sensor readout? If the sensor response is strictly linear, this shouldn't be possible.

So is the answer that the sensor response is not linear? Is this nonlinearity inherent to how the sensor works, or is it a designed feature aimed at increasing the dynamic range?

I'm asking this for my own edification, not because I need the information to accomplish anything.

If you downsample the image (8MP is used in the DXO "print" number), I believe that zero-mean noise tends to average out, and some measure of DR might exceed that of a single sensel.

Which is sort of similar to the print-argument: when you have more spatial resolution than you need, this can be "re-invested" as better "intensity resolution".

-h

Noise, and therefore DR is bandwidth dependent. In imaging, bandwidth is closely linked to pixel count, that is that the pixel count limits the sampling frequency and therefore the bandwidth. If you restrict the signal bandwidth (for instance, by low pass filtering) the noise power is reduced. The 'downsampling' think is a consequence of the low pass filter inherent in downsampling.

-- hide signature --

Bob

Iliah Borg Forum Pro • Posts: 23,645
Re: Dynamic range and RAW file "bit depth"
1

GordonBGood wrote:

szhorvat wrote:

I found this about linearity. The plots show what you said: it's linear in the shadows and the highlights are compressed. I wonder if this compression is engineered in some way (it would make sense to do it).

The data from your link is does indeed show that the output of sensors is non-linear as it approaches saturation electron density of the sensor substrate, but that is a region that is normally never used in most current digital cameras, which only generally use the sensors in there generally linear range. A very fiew cameras (such as the Pentax K-5 series) do push the sensor up into this non-linear range for their extended "lower than base ISO sensitivity" range, which works fine especially if raw development then compensates for the non-linear response.

From my attempts to systemize it, typical histogram for a camera where the full well is used shows a hump in the blown-out area, like this:

I do not see this type of highlights level distribution on Pentax 5-series at ISO 80 setting. Was it some PTC study you did on "5" that shows the full well is used at ISO 80?

-- hide signature --
ArvoJ Senior Member • Posts: 1,367
Re: Questions

Jack Hogan wrote:

Does 18% of saturation in the raw data correspond to middle gray in most DSCs?

Offtopic, but raised interest I found some blog entry, which IMO explains some origins on 18% and 50% equivalence:http://stonerosephotos.com/blog/2010/02/more-on-18-gray/ No connections to specific equipment of course.

-- hide signature --

Arvo
Sigma/Foveon information collection and little galleries:
http://www.stv.ee/~donq/sigma.htm
http://www.stv.ee/~donq/images.htm

 ArvoJ's gear list:ArvoJ's gear list
Sigma SD14 Sigma 10-20mm F4-5.6 EX DC HSM Sigma 105mm F2.8 EX DG Macro +1 more
Y Hafting
Y Hafting Contributing Member • Posts: 787
Non linear for sure.

szhorvat wrote:

Most cameras can record the sensor data with at most 14 bits of resolution. This means that the ratio of the lowest and highest representable values is 2^14.

The dynamic range of a sensor is the ratio between the brightest and dimmest recordable light intensity (or clipping and noise floor). I notice that DxOMark lists several sensors as having a dynamic range larger than 14 EV, e.g. the Nikon D800 has 14.4 EV, which corresponds to a ratio of 2^14.4.

How can they measure a dynamic range higher than the resolution of the sensor readout? If the sensor response is strictly linear, this shouldn't be possible.

So is the answer that the sensor response is not linear? Is this nonlinearity inherent to how the sensor works, or is it a designed feature aimed at increasing the dynamic range?

It is non-linear, but what data exactly is read from the sensor, is something only the sensor manufacturer or inventor could tell. This is why the raw converters from one manufacturer aren't made for processing raw files from others.

A strictly linear raw file would be hugely impractical. For example in bright, the noise is much bigger (in terms of variation in photons) than in dark areas- however we perceive darkness to be more noisy since our eyes are non linear. Thus it makes much more sense to have smaller steps in the shadow areas compared to highlight, and as far as i know this is how data is represented in every sensible format (jpeg, cr2, nef, dng, etc).

There is stricly no need for having the raw file storing the exact sensor readout either. Processing comes cheap compared to storing data, so in theory there is no guarantee that the raw file contains actual raw sensor data. The fact that the image size varies with the visible noise in canons cr2 format indicates that it is compressed.

-Yngve

xpatUSA
xpatUSA Forum Pro • Posts: 12,049
Re: Non linear for sure.

Y Hafting wrote:

There is stricly no need for having the raw file storing the exact sensor readout either. Processing comes cheap compared to storing data, so in theory there is no guarantee that the raw file contains actual raw sensor data. The fact that the image size varies with the visible noise in canons cr2 format indicates that it is compressed.

-Yngve

Quite so!

In the early Foveon-based cameras, a considerable amount of in-camera processing is done, including dark-frame subtraction and especially linearization. For my SD9 camera, Foveon claims 77,000e- for 'well full' but they also mention 45,000e- as being the top of the linear range. They quote 70e- for noise but a possible 40e- with dark frame subtraction.

In terms of 'stops' (on a good day) we might therefore get log2(45,000/40) = 10 stops for reasonably linearity, and about 3/4 stop headroom above that. Foveons need all the headroom they can get

I hate 'stops' in this kind of discussion , a bit of a dB man myself . . . .

-- hide signature --

"Engage Brain before operating Keyboard!"
Ted

 xpatUSA's gear list:xpatUSA's gear list
Panasonic Lumix DMC-G1 Sigma SD14 Sigma SD15 Panasonic Lumix DMC-GH1 Panasonic Lumix G Vario 14-45mm F3.5-5.6 ASPH OIS +13 more
Jack Hogan Veteran Member • Posts: 6,398
Re: Questions

ArvoJ wrote:

completelyrandomstuff wrote:

This is why DXO reports the S/N ratio at 18% btw. This 18% corresponds to 50% gray.

Jack Hogan wrote:

Does 18% of saturation in the raw data correspond to middle gray in most DSCs?

Offtopic, but raised interest I found some blog entry, which IMO explains some origins on 18% and 50% equivalence:http://stonerosephotos.com/blog/2010/02/more-on-18-gray/ No connections to specific equipment of course.

Hi ArvoJ,

Of course. Middle Gray, or L*50, is indeed 18% of 100% diffuse white (or 2.5 stops below it). On the other hand the vast majority of current DSCs tend to spot meter a middle gray card so that it will result in raw values of around +/-10% of saturation (or around 3.5 stops below it). Newer ones even less. Have you checked what your camera does? Mine is around 8%.

Many people here can speak to this issue better than I can. But the jist of the reason for the above is that, with very few exceptions, ADCs respond to incoming light linearly for all intents and purposes. And if middle gray were indeed placed only 2.5 stops below saturation a lot of desirable highlights could be inadvertently blown, making DSC owners unhappy. Film with its gentle rolloff on the other hand ... but I digress.

Hansel Adams placed middle gray in zone V and 'pure white' at zone X. So he thought that there were at least 4+ stops of potentially useful photographic information above it, as any landscape photographer will confirm depending on the scene. That would place middle gray at 5% of saturation or less to be able to capture the 4+ stops of detail above middle gray into the raw data (linearly). But most commercial cameras until about 2008, with useful DRs of only 8 stops or so, simply did not have the 'room' to be able to afford dedicating so much of it to tones above middle gray: the shadows would have been woefully noisy. So they compromised: they typically stuck middle gray around 3+ stops below saturation and clipped some of the potentially desirable highlights - but at least they had decent looking shadows.

As sensors improved, middle gray creeped down: to typically 3.5 stops and beyond. Camera makers came up with systems like Nikon's ADL that, depending on an evaluation of the dynamic range of a scene, would 'underexpose' by up to one stop to fit a more pleasing DR blend into the linear Raw data. Underexposed compared to what? No one knows. They simply make 'better' use of the linear dynamic range available to the camera, making their owners happier.

Cheers,
Jack

xpatUSA
xpatUSA Forum Pro • Posts: 12,049
Re: Questions

The well-respected Doug Kerr asked (rhetorically) if 'gray' is 18% or indeed 12.5% and answered the question at great and detailed length here:

http://dougkerr.net/Pumpkin/articles/Exposure_Calibration.pdf

and here:

http://dougkerr.net/Pumpkin/articles/Scene_Reflectance.pdf

-- hide signature --

"Engage Brain before operating Keyboard!"
Ted

 xpatUSA's gear list:xpatUSA's gear list
Panasonic Lumix DMC-G1 Sigma SD14 Sigma SD15 Panasonic Lumix DMC-GH1 Panasonic Lumix G Vario 14-45mm F3.5-5.6 ASPH OIS +13 more
Iliah Borg Forum Pro • Posts: 23,645
Re: Questions

xpatUSA wrote:

The well-respected Doug Kerr asked (rhetorically) if 'gray' is 18% or indeed 12.5%

It is. In a way.

-- hide signature --
GordonBGood Veteran Member • Posts: 6,306
Re: Dynamic range and RAW file "bit depth"

Iliah Borg wrote:

GordonBGood wrote:

szhorvat wrote:

I found this about linearity. The plots show what you said: it's linear in the shadows and the highlights are compressed. I wonder if this compression is engineered in some way (it would make sense to do it).

The data from your link is does indeed show that the output of sensors is non-linear as it approaches saturation electron density of the sensor substrate, but that is a region that is normally never used in most current digital cameras, which only generally use the sensors in there generally linear range. A very fiew cameras (such as the Pentax K-5 series) do push the sensor up into this non-linear range for their extended "lower than base ISO sensitivity" range, which works fine especially if raw development then compensates for the non-linear response.

From my attempts to systemize it, typical histogram for a camera where the full well is used shows a hump in the blown-out area, like this:

I do not see this type of highlights level distribution on Pentax 5-series at ISO 80 setting. Was it some PTC study you did on "5" that shows the full well is used at ISO 80?

Iliah, the Pentax K-5 series don't push exposure into the non-linear range as far as the camera for which you have shown the raw histogram above with its distinct code density increase toward the brighter end; I estimate that it only pushes about 10% beyond the "normally used" more linear range.

DxOMark full SNR curves for the three Pentax K-5 series cameras (k-5, K-5 II and K-5 IIs) show the effect both numerically and graphically, with the top ISO 80 curve approaching the next ISO 100 curve as the brightness increase toward maximum clipping level, also shown numerically when one curve fits the readings one can obtain by hovering over the graphs as presumably DxOMark have done in order to produce the graphed curves.

If shown in raw histograms, the effect is no where near as strong as you show above with only a slight bump in the curve at the high end.

Regards, GordonBGood

Iliah Borg Forum Pro • Posts: 23,645
Re: Dynamic range and RAW file "bit depth"

GordonBGood wrote:

Iliah Borg wrote:

GordonBGood wrote:

szhorvat wrote:

I found this about linearity. The plots show what you said: it's linear in the shadows and the highlights are compressed. I wonder if this compression is engineered in some way (it would make sense to do it).

The data from your link is does indeed show that the output of sensors is non-linear as it approaches saturation electron density of the sensor substrate, but that is a region that is normally never used in most current digital cameras, which only generally use the sensors in there generally linear range. A very fiew cameras (such as the Pentax K-5 series) do push the sensor up into this non-linear range for their extended "lower than base ISO sensitivity" range, which works fine especially if raw development then compensates for the non-linear response.

From my attempts to systemize it, typical histogram for a camera where the full well is used shows a hump in the blown-out area, like this:

I do not see this type of highlights level distribution on Pentax 5-series at ISO 80 setting. Was it some PTC study you did on "5" that shows the full well is used at ISO 80?

Iliah, the Pentax K-5 series don't push exposure into the non-linear range as far as the camera for which you have shown the raw histogram above with its distinct code density increase toward the brighter end; I estimate that it only pushes about 10% beyond the "normally used" more linear range.

DxOMark full SNR curves for the three Pentax K-5 series cameras (k-5, K-5 II and K-5 IIs) show the effect both numerically and graphically, with the top ISO 80 curve approaching the next ISO 100 curve as the brightness increase toward maximum clipping level, also shown numerically when one curve fits the readings one can obtain by hovering over the graphs as presumably DxOMark have done in order to produce the graphed curves.

If shown in raw histograms, the effect is no where near as strong as you show above with only a slight bump in the curve at the high end.

So it may be that K5 series go into non-linear portion; but even for ISO 80 it does not look that it is more than usual, not full well. If you have it, can you take the data for PTC curve?

-- hide signature --
D Cox Forum Pro • Posts: 19,489
Re: Dynamic range and RAW file "bit depth"

bobn2 wrote:

Not just B&W images in newspapers - essentially all printed images, including the output of inkjet and dye-sub printers. These devices cannot change the intensity of the dye/pigment, only the size of the blob deposited. So they are making an image with a large dynamic range using essentially a 1 bit output.

However, the dot size for half-tone is specified with a number of bits.

For other dithers it gets complicated, but there are still many bits involved.

DSPographer Senior Member • Posts: 2,464
Re: Magic Lantern & analog clipping
1

The Magic Lantern folks think that they have uncovered some extra dynamic range for some Canon DSLR- starting with an improvement of about 1/2 stop for the 5D3:
http://www.magiclantern.fm/forum/index.php?topic=10111.0

It looks like they have changed the gain settings so that instead of hitting the A-D clipping, the full range of the analog amplifiers is used with the analog clipping setting the limit. This is a recent development and I am not sure that they fully understand all the implications of what they are doing on the raw converter software. If the conversion software correctly handles the clipping, this looks to add some ISO settings with real additional DR for the 5D3: but what work needs to be done in the raw converter to be able to correctly deal with the less well defined saturation level?

 DSPographer's gear list:DSPographer's gear list
Canon PowerShot G7 X Canon EOS 5D Mark II Canon EF 24mm f/2.8 Canon EF 50mm f/1.8 II Canon EF 200mm f/2.8L II USM +4 more
Iliah Borg Forum Pro • Posts: 23,645
Re: Magic Lantern & analog clipping
1

what work needs to be done in the raw converter to be able to correctly deal with the less well defined saturation level?

Linearization, normally, based on photon transfer curve. Pretty heavy equipment needed if doing it precisely for that small highlight region; but in practice just three points, the start, the saturation, and some midpoint, using a spline. The other thing necessary is to deal with pattern noise, also not a huge problem.

-- hide signature --
DSPographer Senior Member • Posts: 2,464
Re: bit depth affects PRECISION, not dynamic range so much

John Sheehy wrote:

xpatUSA wrote:

olliess wrote:

It would make more sense to have wider spacing values as the values increase, e.g., something close to logarithmic spacing. (I believe this is what the old Compressed NEF format did with a lookup table).

Correct, see Bill Claff's article here:

I did the math a while back, and I found that a camera that has a RAW saturation of 65K electrons at base ISO needs no more than 300 levels for the top stop, 213 levels for the next stop down, 150 levels for the next stop down, etc, until you are down to where the read noise is statistically dominant and at least 1.3 ADU of your output levels, where you become linear down to the lowest original RAW values.

You really need to avoid histogram shifts in the mapping, though, as they can result in color shifts after white balance.

The linear section becomes unnecessary if you set the correct black level offset. If the linear data is transformed by a square root function (ie a tone curve of gamma=2.0) with the black level before the transformation set to the square of the read noise standard deviation, then the sum of the read and shot noise will yield a constant noise variance in counts after the square root. So if the PRNU is calibrated-out, then the total pixel noise will be constant in counts after the 2.0 tone curve is applied. I modeled this in Matlab in the following post in a thread where I discussed this mapping in more detail:

http://www.dpreview.com/forums/post/52269390

 DSPographer's gear list:DSPographer's gear list
Canon PowerShot G7 X Canon EOS 5D Mark II Canon EF 24mm f/2.8 Canon EF 50mm f/1.8 II Canon EF 200mm f/2.8L II USM +4 more
DSPographer Senior Member • Posts: 2,464
Re: having pondered this, why not have 17 bit raw file option?

RussellInCincinnati wrote:

John Sheehy wrote:

xpatUSA wrote:

olliess wrote:

It would make more sense to have wider spacing values as the values increase, e.g., something close to logarithmic spacing. (I believe this is what the old Compressed NEF format did with a lookup table).

Correct, see Bill Claff's article here:

I did the math a while back, and I found that a camera that has a RAW saturation of 65K electrons at base ISO needs no more than 300 levels for the top stop, 213 levels for the next stop down, 150 levels for the next stop down, etc, until you are down to where the read noise is statistically dominant and at least 1.3 ADU of your output levels, where you become linear down to the lowest original RAW values.

You really need to avoid histogram shifts in the mapping, though, as they can result in color shifts after white balance.

Come to think of it, it wouldn't be skin off of anyone's back to just have a menu option for 17 bit-depth raw files. Totally linear recording of produced-electron counts. Yes you'd be encoding a ton of noise in the least significant bits, slowing down file write times since the numbers written would be less-losslessly-compressible, etc. But certain folks might want it, just like certain folks might want to encode their JPEGs in some other colorspace besides sRGB (an option my cameras have happily let me ignore for many a year now). It's not like any of us care much about raw file size any more. And the raw files would be even raw-er.

This isn't just wasteful of file bits, it also could significantly slow down the raw converter. In column parallel ramp converters like Sony's Exmor sensors use, having a nonlinear ramp dramatically speeds up the conversion process. So, on many cameras that have "14-bit" raw capability the conversion step size is not really uniform, instead it increases approximately as the square root of the level, so that the time to perform the ramp conversion is not excessive.

 DSPographer's gear list:DSPographer's gear list
Canon PowerShot G7 X Canon EOS 5D Mark II Canon EF 24mm f/2.8 Canon EF 50mm f/1.8 II Canon EF 200mm f/2.8L II USM +4 more
Keyboard shortcuts:
FForum MMy threads