Measuring camera gain with CHDK - Creative Uses of CHDK - CHDK Forum

# Measuring camera gain with CHDK

• 2 Replies
• 2934 Views

#### jrincayc

• 2
##### Measuring camera gain with CHDK
« on: 20 / December / 2010, 23:30:56 »
I used CHDK to measure the camera gain (amplification) in a Canon Powershot A640. Once the amplification is known, the
digital pixel values can be converted into physically meaningful units such as interacting photons or numbers of electrons. The details of the method are in
http://www.inl.gov/technicalpublications/Documents/4702567.pdf

#### Microfunguy

• 4037
##### Re: Measuring camera gain with CHDK
« Reply #1 on: 21 / December / 2010, 06:10:44 »
Hello and welcome.

Good to see a scientific application.

Details of the utility programme that separates sensor data into separate colours would be of interest.

David

#### jrincayc

• 2
##### Re: Measuring camera gain with CHDK
« Reply #2 on: 22 / December / 2010, 22:59:20 »
Separating colors isn't very complicated.  First, output the image with dcraw -4 -d
In the dcraw source code it tells different color arrangements for different cameras.  Lets say that it is:
Code: [Select]
`R G R G ...G B G B ...R G R G ...`and so on. Then, read in the output file, and keep track of the x and y coordinates.   In python, you can create two dictionaries, one for the sum and one for the sum squared, with the key being (x % 2,y % 2).  % is the remainder function in python.
So when you have the pixel value, and the x and y coordinates do something like:
Code: [Select]
`key = (x % 2,y % 2)sum[key] = sum.get(key,0.0) + valuesum2[key] = sum2.get(key,0.0) + value**2`Then, at the end, you have two dictionaries with sum[(1,1)] for blue, sum[(0,0)] for red, and two places for the green.

Hope that helps.
« Last Edit: 22 / December / 2010, 23:19:12 by jrincayc »