How exposure settings work - some experiments

csJosh

n3wb
Joined
May 4, 2023
Messages
26
Reaction score
23
Location
United States
Hi All,

I found an API in the SDK to get cameras to tell you the actual gain & shutter value they are using at the moment. Playing around gave me a bit more insight into how the exposure settings work, which I wanted to share in case anyone finds it useful.

The API reports the current gain and shutter speed being used by the camera. As I've played around with the UI camera settings and watched how those numbers change, here's what I think may be going on:

Each pixel in a camera accumulates electric charge as photons hit it during a single frame. When taking a frame of video (or pic), that charge is read and converted to a number. I'm guessing the number is 8-bit, though it could be higher rez. I'm guessing the scale is fixed. E.g., a pre-determined amount of charge will produce "255". There are two knobs that affect the value of the number read:

1. Exposure time. The more time there is for charge to accumulate, the higher the number. If it's dark out, the charge is low, and to prevent it all as reading as 0, 1 or 2, you can just give more time for the charge to build up. Though, as has been mentioned on the forum, a longer exposure time leads to motion blur since a moving object might reflect photons across multiple pixels as it moves during a single frame.

2. Gain. This knob essentially multiplies the amount of charge before it's converted into a number. I think the mutiplication happens in analog (i.e. analog signal amplification). So when it's dark out, rather than waiting for a longer exposure time to accumulate more charge, you can instead crank up the gain, and multiple the charge level you have. The charge level has a "noise floor" - some charge is created just by photons and electrons knocking around inside the detector due to thermal energy. So the charge that is created by outside photons hitting the detector is mixed with the charge created internally due to noise. If the two signals are of comparible strength, you'll see the static as the gain goes high enough to bring both into the 0-255 range.

I believe the "mode"/"Shutter"/"Gain" settings of the "exposure" tab in the camera UI is directing the camera how to set the gain & exposure knob. For example, when set to "manual", you can specify a range for each of the exposure & gain knobs.

It appears that the camera internally is picking the best value it can for exposure & gain, subject to the ranges you set. For example, if the value of "gain" it wants is outside the range you allow in "manual", it will increase the "exposure time" to compensate.

It appears also that the "Exposure comp" nudges the preferred exposure&gain setting, still subject to whatever range limits you have set. It seems like "exposure comp" takes whatever the camera thinks is the best exposure&gain setting at the moment and adds (or subtracts) some amount to both numbers (subject to range limits).

It also appears that the settings in the "Picture" tab, like Brightness & Contrast, do not affect the gain & exposure settings used. I think that means they transform the image after it has been converted from analog charge readings to digital numbers. I have a suspicious that the Backligh WDR (and maybe other backlight settings) also operates in the digital realm, but I could be wrong. It'd be cool if the camera implemented WDR by taking two pictures at different exposure levels, but I'm guessing it's not doing that.

From an information theoretic standpoint, digital transformations can only destroy information, they can not create new information. That includes those Picture and maybe Backlight settings.

This means that to get the best image quality, you should first focus on getting the best exposure/gain settings - that is getting the most detail and preventing washout using the exposure settings. Then to the minimal extent necessary, use the picture & backlight settings.

I'm saying this based on guesswork on what is going on internally in the camera. I could well be wrong.

Oh one caveat: there is a third number reported by the camera status API, called confusingly, "brightness". It doesn't seem related to the brightness & contrast picture settings. It seems somewhat related to the ambient light and exposure level, but I can't figure out the relationship.

For my own camera setup, I had been switching between day & night profiles based on sunrise & sunset, but I'm thinking I might get better results switching based on the gain level the camera is reporting. Just a though I'm hoping to explore.

-Josh
 
Top