# SUB2r

### Site Tools

isp:automatic_white_balance

# Differences

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

 isp:automatic_white_balance [2019/05/09 00:43]Igor Yefmov [Calculate color properties] isp:automatic_white_balance [2019/05/09 00:45] (current)Igor Yefmov [Figure out the adjustment] Both sides previous revision Previous revision 2019/05/09 00:45 Igor Yefmov [Figure out the adjustment] 2019/05/09 00:43 Igor Yefmov [Calculate color properties] 2019/05/09 00:41 Igor Yefmov [Calculate color properties] 2019/05/09 00:38 Igor Yefmov [Collect statistical data set] 2018/06/14 14:47 Igor Yefmov [Sample implementation in C++] 2018/06/14 14:47 Igor Yefmov 2018/06/04 09:12 Igor Yefmov created 2019/05/09 00:45 Igor Yefmov [Figure out the adjustment] 2019/05/09 00:43 Igor Yefmov [Calculate color properties] 2019/05/09 00:41 Igor Yefmov [Calculate color properties] 2019/05/09 00:38 Igor Yefmov [Collect statistical data set] 2018/06/14 14:47 Igor Yefmov [Sample implementation in C++] 2018/06/14 14:47 Igor Yefmov 2018/06/04 09:12 Igor Yefmov created Line 56: Line 56: Now that we have all the information we need to make a decision let's make one! Now that we have all the information we need to make a decision let's make one! - - If the **absolute** value of average ''U'' is above some arbitrary threshold (we use ''0.1'') then we need to adjust the ''Blue'' channel. In our case we just change the sensor's blue channel gain by multiplying it by the ''B/G'' ratio + - If the **absolute** value of average $U$ is above some arbitrary threshold (we use $0.1$) then we need to adjust the ''Blue'' channel. In our case we just change the sensor's blue channel gain by multiplying it by the $^B/_G$ ratio - Be careful not to overflow beyond the sensor gain's cap - Be careful not to overflow beyond the sensor gain's cap - If the gain is already at 0 and needs to be increased - make sure you use addition, as multiplication won't help you((or just make sure you never adjust the color channel's gain below, say, ''10'')) ;-) - If the gain is already at 0 and needs to be increased - make sure you use addition, as multiplication won't help you((or just make sure you never adjust the color channel's gain below, say, ''10'')) ;-) - - Same for the ''Red'' channel, only we use the ''V'' and ''R/G'' values + - Same for the ''Red'' channel, only we use the $V$ and $^R/_G$ values - The ''Blue'' channel gets a bit over-saturated on the sensor we use so a tiny adjustment is introduced: the ''B/G'' ratio is offset by ''2%'' right before it is applied to the new gain's value. + The ''Blue'' channel gets a bit over-saturated on the sensor we use so a tiny adjustment is introduced: the $^B/_G$ ratio is offset by $2%%$ right before it is applied to the new gain's value. ===== Sample implementation in C++ ===== ===== Sample implementation in C++ ===== [[Sample AWB 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 deduce from their usage [[Sample AWB 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 deduce from their usage