Black level importance in RAW - RAW Shooting and Processing - CHDK Forum

Black level importance in RAW

  • 18 Replies
  • 11415 Views
*

Offline Lebeau

  • ***
  • 187
Black level importance in RAW
« on: 08 / November / 2011, 19:32:26 »
Advertisements
With the appreciated help of this forum moderators and experts, I correct my mind and post #17 represent what I expected to express.

The following quote was the original first post. I kept it to remind me how minds can get confused :(
With a little time this afternoon, I want to talk about the importance of the black level of photosensors used in a digital camera.

The black level of a photosensor is determined by the level of noise inherent in the technology, CCD, C-MOS, BSI-C-MOS ... when the sensor actually captures the total darkness (with a cap on, a black frame with long exposure, or ...), the raw yields values ​​greater than zero because of the noise. For example, the 5 least significant bits of a CCD sensor to provide random values and represent a normal distribution around a mean value. Bar chart below shows the distribution function values ​​"black" [Number pixels (0 .. 1500) Vs Pixel value (0 .. 65)]



Notes that, of 1500 pixels sampled, the median value (750 pixels) is close to the black level of the unit, 31 (2^5-1).  Thus, the demosaicking software uses this black (31 = 2 ^ 5-1) and white (2 ^ 10-1 for a 10-bit) values before making any changes in the sensor values, Raw to RGB regardless of the color space used (Cie, Prophoto, LR, sRGB, ...)

Note also that the presence of pixels with values ​​above 31 (about 700 of 1500) will be considered non-black and produce a noise appearance and apparent noise.

Having set the black level to 63 (2 ^ 6-1) would have eliminated the appearance of noise in the dark but it would have remained apparent for higher values. Another option would be to truncate the 6 least significant bits to remove the random values ​​and keep only the 4 most significant bits. The problem that flows from it is only 4 bits and only 16 possible values! 0 to 15!

Only way to reduce the appearance of noise is to use software for noise reduction taking into account the perception of the human eye, so that it plays tricks on us. Here we talk about noise filter before demosaicking, before the creation of virtual colors.

Can a 12-bit sensor is better?

The level of a white on 12 bits is (2 ^ 12-1). The black level for a Canon CCD is 7 bits (127 = 2 ^ 7-1). So 12 bits stored in the raw, 7 bits are random. There are only 5 significant bits, as for the 10-bit CCD. The 10-bit and 12-bit refer to the photon-to-digital converter, the sensor is 5-bits accurate (or inaccurate depending on your perspective).

Do catch the other parameters (iso, ev, tv, av, ...) have an impact on the black level?

To my knowledge, Canon and Sony use sensors whose size is greater than the final image raw. Thus, an area not exposed to light, is dedicated to assessing the level of black. In these cases, no need for a black frame (without recapturing lights), the sensor with simultaneously capture both. By cons, it is necessary that this "black box" is used by the demosaicking software, umm, less certain.

Is a C-MOS is greater than 14 bits? To compare the accuracy of a real sensor, how do I determine the level of black?

The level of white is 2 ^ 14-1. For the black level it's relatively simple, you take a picture with the lens cap, so completely black. You analyze the resulting values ​​of the raw, binary analysis, not an LR analysis. You count values ​​to obtain a graph similar to the previous. The median should be close to the black level. At that time, you will know how many bits are significant.

I hope I've not lost along the way. If I can clarify, ..., I will be happy to photonise you.

P.S.: To simplify
For a CCD sensor, the raw numeric value recorded by each pixel of a sensor reads:
Value (10 bits) = Photon (0 .. 31) * 32 + random (0 .. 31)
Value (12 bits) = Photon (0 .. 31) * 128 + random (0 .. 127)

So, no matter the analogue-digital converter operating at 10 bits or 12 bits, the counting of photons is accurate to one part in 32, the remaining bits is random!
« Last Edit: 18 / November / 2011, 11:47:04 by Lebeau »

Re: Black level importance in RAW
« Reply #1 on: 09 / November / 2011, 00:13:07 »

deleted - off topic
« Last Edit: 11 / November / 2011, 09:29:19 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3332
    • Photos
Re: Black level importance in RAW
« Reply #2 on: 09 / November / 2011, 01:07:31 »
No, a black level of 63 for 10 bit sensor or 127 for 12 bit sensor does not mean that there are only 5 bits of valid image data per pixel.
Saying that the bottom 5 or 7 bits is random noise is just wrong.

It means that the valid values for each pixel range from 63 - 1023 (10 bit) or 127 - 4095 (12 bit).

For example think about the top 2048 values for a 12 bit sensor - once the number of photons hitting the sensor has reached this threshold then the sensor noise and shot noise component is irrelevant. Each and every value from 2048 to 4095 is a valid value with a neglible noise component.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline fe50

  • ******
  • 3134
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: Black level importance in RAW
« Reply #3 on: 09 / November / 2011, 01:16:10 »
Maybe the CHDK wiki needs a "CHDK Photography in Depth" section ? Should we start one  - its free ?
* http://chdk.wikia.com/wiki/Category:CHDK_internals


*

Offline Lebeau

  • ***
  • 187
Re: Black level importance in RAW
« Reply #4 on: 09 / November / 2011, 06:19:20 »
No, a black level of 31 for 10 bit sensor or 127 for 12 bit sensor does not mean that there are only 5 bits of valid image data per pixel.
Saying that the bottom 5 or 7 bits is random noise is just wrong.

It means that the valid values for each pixel range from 31 - 1023 (10 bit) or 127 - 4095 (12 bit).

For example think about the top 2048 values for a 12 bit sensor - once the number of photons hitting the sensor has reached this threshold then the sensor noise and shot noise component is irrelevant. Each and every value from 2048 to 4095 is a valid value with a neglible noise component.

Phil.

Note: For 10 bits, I change 63 to 31 for black level

I already think about and understand your point. I am still thinking about to clearly express the real interpretation.

I understand that a cell value, for 10b sensor, could be interpret with uncertainty as per 31 +/- 31 for a black cell. And it can go up to 1023 +/- 31 for a fully photon-loaded cell. I understand that relative uncertainty would go from 100% to 3%. I understand that raw to XYZ conversion will use black-white cell range (31 to 1023). I understand that, after photons are aggregated, the analog-digital converter convert something, the photon counts, instead of nothing.

But, consider, ...
 - for white cell, I have 1023 +/- 31 as cell value. This saturated and converted cell would have really count between 992 and 1054 "photons",
 = in binary "1111100000" .. "10000011110" (5 msb: "11111" [31 !] .. "1-00000" [32 !+])

 - for black cell, I have 31 +/- 31 that correspond to a range between 0 to 62,
 = in binary  "0000000000" .. "0000111110" (5 msb: "00000" [0 !] .. "00001" [1 !+])

 - for a "mid" range value (not gamma corrected ! ), consider I have 63 +/- 31 that correspond to a range between 32 to 94,
 = in binary "0000100000" .. "0001011110" (5 msb: "00001" [1 !] .. "00010" [2 !+])

This is how uncertainty is express within black-level value, irrelevant to cell value. I understand that signal to noise quality is increased when increasing photon count, from 1 to 33 , but it's still the 5 most significant bits that are the "usable" value.

*

Offline philmoz

  • *****
  • 3332
    • Photos
Re: Black level importance in RAW
« Reply #5 on: 09 / November / 2011, 07:15:40 »
I'm sorry; but this is just wrong. Image sensors do not work like that.

Each bit corresponds to 1 stop of light in the image. So on a 10 bit sensor there are 512 values available for the brightest part of the image, 256 for the next stop, 128 for the next, and so on. A 10 bit sensor has a theoretical 10 stop dynamic range; but the black level and shot/sensor noise reduce this; but not the way you are implying.

If your theory was correct then both 10 and 12 bit sensors would have only a 5 stop dynamic range which clearly they do not. And there would be no reason to go from 10 to 12 bit sensors (or from 12 to 14 on DSLR's).

The black level does not define the amount of noise per pixel - it defines the minimum value that each pixel will have due to shot and sensor noise. In other words on a 10 but camera you will never get a pixel value less than 31 no matter how dark the exposure.

Every pixel value above the black point is valid - the amount of noise is determined primarily by the sensor gain (ISO) not the black level. For a 10 bit sensor there are ~990 valid values for each pixel not 32.

To put it another way, the black level does not randomise the bottom 5 (or 7 bits), it shifts the lowest value available up from 0 to 31 (or 127).

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline Lebeau

  • ***
  • 187
Re: Black level importance in RAW
« Reply #6 on: 09 / November / 2011, 11:05:05 »
philmoz, I will not debate your point of view. I understand your arguments, they are generally admitted but wrong from my experience. I was thinking like that before I build the black-level distribution I include.

For 10b system, I repeat, the 5 lsb are noise, leaving only 5 msb to "real" signal. Take a fully black picture you will find the same distribution. Take a fully noiseless neutral-grey picture, you would get similar distribution. The 5 msb would be near identical but the 5 lsb would be random as per black-level.

The black-level don't randomize the 5 lsb, I agree. The causality is set on the other way, the 5 lsb noise cause the black-level to be set at 31 !!! On 12b system, the 7 lsb noise cause the black-level to be set at 127 !!!

*

Offline philmoz

  • *****
  • 3332
    • Photos
Re: Black level importance in RAW
« Reply #7 on: 09 / November / 2011, 16:55:24 »
This isn't my 'point of view'.
It's fact based on physics and mathematics.

If your 'discovery' were correct why has it never been noticed before?
How could the likes of DXOMark and DPReview, who do extensive testing testing of RAW files from many cameras, have missed something like this?

Have a look at these to get a better understanding of how sensors work and how to correctly measure noise:
http://en.wikipedia.org/wiki/Image_noise
http://www.clarkvision.com/articles/evaluation-1d2/

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)


*

Offline Lebeau

  • ***
  • 187
Re: Black level importance in RAW
« Reply #8 on: 10 / November / 2011, 09:08:26 »
Ok !

Suppose I insert, on my 10b A650, the following transformation in raw.c, just after "if conf.save_raw" (note: to toggle this process on/off upon raw on/off)
Code: [Select]
register int x;
register int y;
register int val;
for ( y = CAM_ACTIVE_AREA_Y1; y < CAM_ACTIVE_AREA_Y2; y++ ) {
for ( x = CAM_ACTIVE_AREA_X1; x < CAM_ACTIVE_AREA_X2; x++ ) {
val = get_raw_pixel ( x, y );
val = ( ( val >> 5 ) << 5 ) + ( CAM_BLACK_LEVEL + 1 ) * ( ( val % ( CAM_BLACK_LEVEL + 1 ) ) > ( CAM_BLACK_LEVEL >> 1 ) );
val = ( ( val > CAM_WHITE_LEVEL ) ? 0x3E0 : val );
set_raw_pixel ( x, y, val );
};
};

Upon my knowledge, this code will :
( ( val >> 5 ) << 5 ): truncate 5 lsb [leaving 5 msb]
( ( val % ( CAM_BLACK_LEVEL + 1 ) ) > ( CAM_BLACK_LEVEL >> 1 ) ): return 0/1 upon 5 lsb > half black level
.. ( CAM_BLACK_LEVEL + 1 ) *.. :  add 32 * 0/1 to the truncated 5 lsb

Therefore raw data contains only 5 msb values, rounded to the nearest 5 msb "integer"

How look this image ? Here are 25% scaled jpegs with 10b and 5msb

Note: this process did not eliminate non-black noise, nor black noise, it only expose proper removal of 5 lsb

*

Offline philmoz

  • *****
  • 3332
    • Photos
Re: Black level importance in RAW
« Reply #9 on: 10 / November / 2011, 15:16:49 »
Firstly scaling the images averages out the values so hides the effect - look at 100% images and you should see the difference a lot more clearly

Even so those images prove my point - look at the top of the cabinet.
There is no longer a smooth gradient here.
This shows that you have removed valid image data not noise.

You didn't answer my question - how is it that no other company heavily invested in this area has ever noticed this?

Quote
Note: this process did not eliminate non-black noise, nor black noise, it only expose proper removal of 5 lsb

I'm sorry, I'm not familiar with these terms. What is 'non-black noise' and 'black noise'? Please provide links to the scientific definitions of these terms.

Did you take the time to read the links I posted?

Phil.



CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

 

Related Topics