This code cycle through image[] 8x8 blocks, skip blocks with data near sensor saturation and calculates pixel sum/count for other (non-saturated) blocks to get mean per-channel values.
This code assumes entire image is (average) gray. If not, auto-WB will not work well.[/geshifilter-c]
There is no exposed function.
You may steal code from internal\dcraw_common.cpp:scale_colors() function;
Starting with
And up to final calculation of pre_mul:
This code cycle through image[] 8x8 blocks, skip blocks with data near sensor saturation and calculates pixel sum/count for other (non-saturated) blocks to get mean per-channel values. This code assumes entire image is (average) gray. If not, auto-WB will not work well.[/geshifilter-c]