[{"id":25133,"web_url":"https://patchwork.libcamera.org/comment/25133/","msgid":"<20220927092127.wwdapq565jehzzmk@uno.localdomain>","date":"2022-09-27T09:21:27","subject":"Re: [libcamera-devel] [PATCH v5 33/33] ipa: rkisp1: awb: Remove\n\tbias from gain calculation","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent\n\nOn Tue, Sep 27, 2022 at 05:36:42AM +0300, Laurent Pinchart via libcamera-devel wrote:\n> The red and blue gains are computed by dividing the green mean by the\n> red and blue means respectively. An offset of 1 is added to the dividers\n> to avoid divisions by zero. This introduces a bias in the gain values.\n> Fix it by clamping the divisors to a minimum of 1.0 instead of adding an\n> offset.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 7 ++++---\n>  1 file changed, 4 insertions(+), 3 deletions(-)\n>\n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index eb32cd722071..3349948a3acf 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -280,10 +280,11 @@ void Awb::process(IPAContext &context,\n>\n>  \t/*\n>  \t * Estimate the red and blue gains to apply in a grey world. The green\n> -\t * gain is hardcoded to 1.0.\n> +\t * gain is hardcoded to 1.0. Avoid divisions by zero by clamping the\n> +\t * divisor to a minimum value of 1.0.\n>  \t */\n> -\tdouble redGain = greenMean / (redMean + 1);\n> -\tdouble blueGain = greenMean / (blueMean + 1);\n> +\tdouble redGain = greenMean / std::max(redMean, 1.0);\n> +\tdouble blueGain = greenMean / std::max(blueMean, 1.0);\n>\n>  \t/*\n>  \t * Clamp the gain values to the hardware, which expresses gains as Q2.8\n> --\n> Regards,\n>\n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0422AC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Sep 2022 09:21:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C7BC96226E;\n\tTue, 27 Sep 2022 11:21:30 +0200 (CEST)","from relay10.mail.gandi.net (relay10.mail.gandi.net\n\t[IPv6:2001:4b98:dc4:8::230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A64361F7B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Sep 2022 11:21:30 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 9DBA1240015;\n\tTue, 27 Sep 2022 09:21:29 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1664270490;\n\tbh=h9Gawvk9tEOpz9EmIq3SSEyfYAl6bDASy0GE6uwA4Y0=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=NRG/Txu/9yj8Tcy/ZXf3+0NXbR2lBLaARnuOS7lTacbNwdDVtq9xxjgl8LNiTqo5+\n\tOpr0KVV9EYIKXF/93yb4Kj7zj0cfPt/WPSiyVJTPzyZupXdvZtNqZVs83Ox0phSsw5\n\tRGrdDijIS3f7W0s7gbfXQ+M8deWBkYVS1tU/LqGt0UByaV6vVL+Baohnw2He6mJPyy\n\tdBjaXM29GGwsW5bXYYxNXU5pbHE6itSe4JSyyzkLbuJsyqGt6piTh2nNjFDf/wEPc2\n\tj8mUmRjbLBzxSfnxE1+d3mrKFntyQGBbyqLV8PCQSxCbgbrplS9emGfJZEdIro1iRl\n\t6Rj9NeTwgsigg==","Date":"Tue, 27 Sep 2022 11:21:27 +0200","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20220927092127.wwdapq565jehzzmk@uno.localdomain>","References":"<20220927023642.12341-1-laurent.pinchart@ideasonboard.com>\n\t<20220927023642.12341-34-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220927023642.12341-34-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v5 33/33] ipa: rkisp1: awb: Remove\n\tbias from gain calculation","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]