User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
isp:automatic_exposure [2018/06/04 11:14] – [Decide the action to take] Igor Yefmovisp:automatic_exposure [2022/04/04 23:32] (current) – external edit 127.0.0.1
Line 5: Line 5:
 ====== Effects of Black Level, Gains, and "Exposure" ====== ====== Effects of Black Level, Gains, and "Exposure" ======
  
-Below are a few sections that provide a bit of information on what effect each of the 3 types of digital settings have on the output image+Below are a few sections that provide a bit of information on what effect each of the 3 types of digital settings have on the output image.
  
 ===== Black Level ===== ===== Black Level =====
  
-[[https://en.wikipedia.org/wiki/Black_level|Black level]] basically tells the sensor which level of brightness to consider "true black". If you take a look at the brightness histogram of a given image the value of the Black Level will directly correspond to the gap at the left edge of that histogram, where there are no pixels reported to be of such low brightness value. Increasing the Black Level too high will cause the image to look washed out while using a too low of a setting causes some grey pixels to be mistakenly read as pitch black.+[[https://en.wikipedia.org/wiki/Black_level|Black level]] basically tells the sensor which level of brightness to consider "true black". If you take a look at the brightness histogram of a given imagethe value of the Black Level will directly correspond to the gap at the left edge of that histogram, where there are no pixels reported to be of such low brightness value. Increasing the Black Level too high will cause the image to look washed outwhile using a too low of a setting causes some grey pixels to be mistakenly read as pitch black.
  
-Remember: the brighter the pixel the **lower** it'read charge. So increasing the Black Level causes more pixels to be considered "brighter than black" and lowering the Black Level value causes more off-black (grey) pixels to be reported as solid black as in "these pixels were not bright enough to be considered lit".+Remember: the brighter the pixelthe **lower** its read charge. So increasing the Black Level causes more pixels to be considered "brighter than black" and lowering the Black Level value causes more off-black (grey) pixels to be reported as solid blackas in "these pixels were not bright enough to be considered lit".
  
 ===== Gains ===== ===== Gains =====
Line 19: Line 19:
 ==== Individual color channel gains ==== ==== Individual color channel gains ====
  
-There are 3 individual Gain settings for each of the 3 color channels (Red, Green, Blue) and those are applied to pixel data corresponding to that color. Naturally changing these values has a profound effect on the output color.+There are 3 individual Gain settings for each of the 3 color channels (Red, Green, Blue) and those are applied to pixel data corresponding to that color. Naturally changing these values has a profound effect on the output color.  The offset to increasing gain is that it will increase the noise.
  
 ==== Global Gain ==== ==== Global Gain ====
  
-Global Gain is a Gain that is applied to **every** pixel. Adjusting this setting greatly affects the brightness of the picture while only minimally affecting the color balance.+Global Gain is a Gain that is applied to **every** pixel. Adjusting this setting greatly affects the brightness of the picture while only minimally affecting the color balance. The offset to increasing gain is that it will increase the noise.
  
 ===== "Exposure" ===== ===== "Exposure" =====
  
-The timing generator outputs clocks to access the rows of the imaging array, precharging and sampling the rows of the array sequentially. In the time between precharging and sampling a row, the charge in the pixels decrease with exposure to incident light. This is the exposure time in rolling shutter architecture.+The timing generator outputs clocks to access the rows of the imaging array, pre-charging and sampling the rows of the array sequentially. In the time between pre-charging and sampling a row, the charge in the pixels decreases with exposure to incident light. This is the exposure time in rolling shutter architecture.
  
 The exposure time is controlled by adjusting the time interval between pre-charging and sampling. After the data of the pixels in the row has been sampled, it is processed through analog circuitry to correct the offset and multiply the data with corresponding Gain. Following analog processing is the ADC which outputs 10, 12, or 14 bits((depends on the sensor chip's model)) of data for each pixel in the array. The exposure time is controlled by adjusting the time interval between pre-charging and sampling. After the data of the pixels in the row has been sampled, it is processed through analog circuitry to correct the offset and multiply the data with corresponding Gain. Following analog processing is the ADC which outputs 10, 12, or 14 bits((depends on the sensor chip's model)) of data for each pixel in the array.
Line 46: Line 46:
   - The global brightness average (arithmetic mean) should be in a comfortable zone around 90-100 (assuming [0..255] range for brightness)   - The global brightness average (arithmetic mean) should be in a comfortable zone around 90-100 (assuming [0..255] range for brightness)
   - Black level should be set to correctly reflect the visual perception of the scene and the image's rendering on a display   - Black level should be set to correctly reflect the visual perception of the scene and the image's rendering on a display
- 
-===== Black Level ===== 
- 
-As the sensor processes input its electrical characteristics could fluctuate (due to, for example, heating up) requiring a manual human intervention to set an appropriate Black level (or an automated "Black level Calibration" procedure, if implemented by the sensor chip). 
  
 ===== Exposure step-by-step algorithm ===== ===== Exposure step-by-step algorithm =====
Line 55: Line 51:
 The following steps describe the auto-exposure procedure in a top-down approach: The following steps describe the auto-exposure procedure in a top-down approach:
   - [[#Collect statistics]]   - [[#Collect statistics]]
-  - [[#Decide the action to take]] and based on that:+  - [[#Decide on action to take]] and based on that:
     - No adjustment needed - loop back to step one     - No adjustment needed - loop back to step one
     - [[#Increase the brightness]]     - [[#Increase the brightness]]
Line 74: Line 70:
 Once we have the above two factors figured out the decision tree looks as follows: Once we have the above two factors figured out the decision tree looks as follows:
 <code cpp> <code cpp>
-enum class ExpCorrAction{STAYINCDEC};+enum class ExpCorrAction{stayincdec};
 ExpCorrAction _needExpCorrection(int _right, double _adjY){ ExpCorrAction _needExpCorrection(int _right, double _adjY){
-    if(_right > 60 && _adjY < 0.97){ +    if(_right > 60 && _adjY < 1){ 
-        return ExpCorrAction::DEC;  // there are pixels at level 100+ and we were asked to dim the image+        return ExpCorrAction::dec;  // there are pixels at level 100+ and we were asked to dim the image
     }     }
     if(_right >= 250 && _adjY <= 1){     if(_right >= 250 && _adjY <= 1){
-        return ExpCorrAction::DEC;  // there are more overexposed pixels than the threshold and dimming the image+        return ExpCorrAction::dec;  // there are more overexposed pixels than the threshold and dimming the image
     }     }
-    if(_right < 240 && _adjY > 1.2){ +    if(_right < 240 && _adjY > 1){ 
-        return ExpCorrAction::INC;  // there's room to grow and asked to increase brightness+        return ExpCorrAction::inc;  // there's room to grow and asked to increase brightness
     }     }
-    return ExpCorrAction::STAY;+    return ExpCorrAction::stay;
 } }
 </code> </code>
Line 93: Line 89:
   - If we have not reached the limit on Exposure setting - increase it by multiplying by the target/real brightness ratio   - If we have not reached the limit on Exposure setting - increase it by multiplying by the target/real brightness ratio
   - Else, if we have not hit the Global Gain limit - increase it by multiplying by the target/real brightness ratio   - Else, if we have not hit the Global Gain limit - increase it by multiplying by the target/real brightness ratio
-  - Else (special case!) **only** if the auto-white balance is currently turned **on** and if the brightness adjustment is very high (above ''4'') and if the Red and Blue channel'Gains are not maxed out then **carefully** increase the Green Gain. By "carefully" I mean the following:+  - Else (special case!) **only** if the auto-white balance is currently turned **on** and if the brightness adjustment is very high (above ''4'') and if the Red and Blue channels' Gains are not maxed outthen **carefully** increase the Green Gain. By "carefully" I mean the following:
     - Never increase the Green Gain beyond ''1180''     - Never increase the Green Gain beyond ''1180''
     - Only increase the Green Gain as much as to not cause the overflow for the Gains in Red or Blue channels (take a conservative guess and then lower it by another ''5%'')     - Only increase the Green Gain as much as to not cause the overflow for the Gains in Red or Blue channels (take a conservative guess and then lower it by another ''5%'')
Line 104: Line 100:
   - If the Global Gain is already at ''0'' - decrease the Exposure by multiplying it by the target/real brightness ratio   - If the Global Gain is already at ''0'' - decrease the Exposure by multiplying it by the target/real brightness ratio
  
 +===== Black Level =====
 +
 +As the sensor processes input its electrical characteristics could fluctuate (due to, for example, heating up) requiring a manual human intervention to set an appropriate Black level (or an automated "Black level Calibration" procedure, if implemented by the sensor chip).
 +
 +In order to automate this process one could think of Black Level as the counterpart to the overexposure. The goal is to have the Black Level set at such value as to ensure that there are no more than specified overexposure pixel count that are pitch black.
 +
 +===== Sample implementation in C++ =====
 +
 +[[Sample AE implementation in C++]] shows one possible implementation of the approach described above. It does use (without much explanation) some of the external structures, but those should not be hard to comprehend from their usage

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information