| Message ID | 20261102165032.3921934-1-stefan.klug@ideasonboard.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
Quoting Stefan Klug (2026-11-02 16:50:16) > In AgcMeanLuminance::estimateInitialGain() a constant value of 0.001 is > added to yValue. This is there to prevent division by 0 in cases where > yValue is 0. This offset produces a noticeable error in the gain > calculation (Which is especially annoying when doing hand calculations > to check the correct inner workings of the algorithms). > > Fix that by replacing the fixed offset by a max() function. > > Reorder the parameters to the outer min() for better readability. > > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > src/ipa/libipa/agc_mean_luminance.cpp | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp > index cdfca47a3485..5b0a6e259433 100644 > --- a/src/ipa/libipa/agc_mean_luminance.cpp > +++ b/src/ipa/libipa/agc_mean_luminance.cpp > @@ -527,7 +527,8 @@ double AgcMeanLuminance::estimateInitialGain(const Traits &traits, double yTarge > */ > for (unsigned int i = 0; i < 8; i++) { > double yValue = traits.estimateLuminance(yGain); > - double extra_gain = std::min(10.0, yTarget / (yValue + .001)); > + double extra_gain = std::min(yTarget / std::max(yValue, 0.001), > + 10.0); > > yGain *= extra_gain; > LOG(AgcMeanLuminance, Debug) << "Y value: " << yValue > -- > 2.53.0 >
diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp index cdfca47a3485..5b0a6e259433 100644 --- a/src/ipa/libipa/agc_mean_luminance.cpp +++ b/src/ipa/libipa/agc_mean_luminance.cpp @@ -527,7 +527,8 @@ double AgcMeanLuminance::estimateInitialGain(const Traits &traits, double yTarge */ for (unsigned int i = 0; i < 8; i++) { double yValue = traits.estimateLuminance(yGain); - double extra_gain = std::min(10.0, yTarget / (yValue + .001)); + double extra_gain = std::min(yTarget / std::max(yValue, 0.001), + 10.0); yGain *= extra_gain; LOG(AgcMeanLuminance, Debug) << "Y value: " << yValue
In AgcMeanLuminance::estimateInitialGain() a constant value of 0.001 is added to yValue. This is there to prevent division by 0 in cases where yValue is 0. This offset produces a noticeable error in the gain calculation (Which is especially annoying when doing hand calculations to check the correct inner workings of the algorithms). Fix that by replacing the fixed offset by a max() function. Reorder the parameters to the outer min() for better readability. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> --- src/ipa/libipa/agc_mean_luminance.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)