How does rawPy reads DNG frames

2.4k views Asked by At

This question is the follow up of my previous one dng-raw-pictures-imported-as-16-bit-deep-but-unexpected-plt-show-result after which I continued my search.

Due to the replies obtained the visualization in 16 bit but channel per channel works well. I decided to take a series of 50 BIAS frames. This are pictures taken with ISO 100 and an exposure time of 1/8000s (shortest exposure with lowest ISO) in the complete dark. The bias frame shows what the sensor sees when no light is coming in, and the ADC behind the sensor should give for every pixel a "0" value. This is not always the case, and I want to analyze how much this value changes. I do not expect big variation or big error values.

With the method explained in my previous question, I read my 50 frames one by one and look at the R, G, B values of a random pixel (random but always the same one), let us say the pixel with position [1500, 1500].

While running through the sequence I compare the pixel value with the mean of the row and the column. Beside the average value I also calculate the standard deviation of the row and the column.

This is what I found:

Analysis ISO 100, Exp 1/8000s

Personally I find these fluctuations huge and did not expect this for an ADC with 14bit depth. Probably there is something wrong with the way I look to the data and I hesitate but fear it has to do again with something as ColorMapping, Demosaicing etc.

In order to cross check, I wanted to be sure that the values I obtain from my Python script for pixel [1500,1500] can be reproduced. Therefor I installed ImageJ or also called in its last version Fiji. With the DCRAWreader plugin I could read the same 16 bit frame and use the Pixel Inspect tool in order to look up the values of the famous pixel in position [1500,1500].

The ImageJ values do NOT correspond with the ones I obtained with Python.

My problem is now: "How should I interpret the rgb figures behind a pixel of a picture uploaded in Python? How do they relate to the number of electrons generated in the sensor well of the pixel and converted by the ADC into a digital value?"

1

There are 1 answers

0
letmaik On

The postprocessing options and their defaults can be found at https://letmaik.github.io/rawpy/api/rawpy.Params.html.

When creating statistics on bias frames you need to disable any mechanisms that automatically adjust brightness etc. The following options should make your plots a lot more meaningful: output_bps=16, no_auto_scale=True, no_auto_bright=True, gamma=(1,1).

You can also go one step further and do your analysis on the non-interpolated RAW Bayer data by accessing raw.raw_image which is a 2D numpy array.

There should be a more or less linear relation between the number of electrons and the RAW values, however it's pretty much impossible without calibration to assign RAW values to electron counts. This is especially true for consumer grade cameras which apply transforms even to the RAW values.