how to get raw data bit depth information??

how to get the bitdepth of raw data, like 12bpp, 14bpp and etc???

Forums: 

There is no such things as a

There is no such things as a 'bit depth':

Imagine Sony ARW2 format (described in details here: http://www.rawdigger.com/howtouse/sony-craw-arw2-posterization-detection ):
- local 7-bit lossy storage
- 11-bit non-linear after lossy (de)compression
- 0..17204 data range after linearization curve (so, 'more than 14bits'

Also, advertized as 14-bit ADC (Sony A7 series), but data gapped even in shadows).

So, what bitdepth?

LibRaw provides data range (maximum value) in imgdata.color.maximum

-- Alex Tutubalin

hi, Alex

hi, Alex
thanks for reply. i am a ISP algorithm engineer. i use libraw for read dng and cr2 files for algorithm tunning.
usually sensor will output raw data in some bit width, such as 10bit, 12bit 14bit in mipi interface. which bit information will be used in my c-model.

as you mentioned, Libraw provides maximum value in imgdata.color.maximum. for 14bit sensor output, i see the maximum value will be 0x3f60, which is less than 0x3fff. so may i need write some codes to detect the highest non-zero bit so that i can know the real bits (14 in this case)in 16 bit data.

anyway, thanks for you reply. libraw is really helpful for me. thanks verymuch

In first assumption, you're

In first assumption, you're right: there is ADC with fixed bit count, so data range should fit into this range.
But things are more complicated:

1. Some cameras use full pixel capacity at base (lowest) ISO, so data maximum is lower.
See this article: http://www.rawdigger.com/howtouse/rawdigger-histograms-overexposure-shapes
and inspect Panasonic histograms at low iso
(You may also find RawDigger software very useable for your work, to see raw data 'as is')

2. Some cameras alter RAW data in some way (Sony lossy compression mentioned above and many other formats with highlights compression tone curve), so data range is not same as ADC range

2b. Some cameras may subtract 'black level' (bias) before raw values recording, thus resulting in lower maximum values.

2c. Some cameras may clip data below ADC maximum value to avoid ADC non-linearity (many Canon cameras).

Using wrong maximum value in processing will result into false colored highlights: http://blog.lexa.ru/2010/03/28/taina_rozovykh_oblakov.html (sorry, it is in russian, but google translate will do the trick).

-- Alex Tutubalin