{"id":17444,"url":"https://patchwork.libcamera.org/api/1.1/patches/17444/?format=json","web_url":"https://patchwork.libcamera.org/patch/17444/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220927023642.12341-34-laurent.pinchart@ideasonboard.com>","date":"2022-09-27T02:36:42","name":"[libcamera-devel,v5,33/33] ipa: rkisp1: awb: Remove bias from gain calculation","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"df58e9c7fd2142d9f592ef3c9e686529853d79bb","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17444/mbox/","series":[{"id":3506,"url":"https://patchwork.libcamera.org/api/1.1/series/3506/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3506","date":"2022-09-27T02:36:09","name":"ipa: Frame context queue, IPU3 & RkISP consolidation, and RkISP1 improvements","version":5,"mbox":"https://patchwork.libcamera.org/series/3506/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17444/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17444/checks/","tags":{},"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 46C3BC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Sep 2022 02:37:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 12A5362383;\n\tTue, 27 Sep 2022 04:37:54 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 18AE362369\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Sep 2022 04:37:51 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 88EA647C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Sep 2022 04:37:50 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1664246274;\n\tbh=cYsCTrk5122uifEVEu5V4F9/P4MluZ7OC+U6xLpN+uI=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=z2P+FFyWiDso1Zpib7J/T9JY9f9XYuPkLUD0enXAdd0vca46meBPe3OAYx2phK2In\n\ti4DwPfZ4fz7GS7mA4FbHISZSRmy6zKCTLg8BpARkeGZ14/8sdTZNO5ctm0l54kWt6/\n\t0F+o4EMjMu86VVGSVFqE3pDy6+4TF3nScRusQY754FPK8FlVSOQzCc0olXoe9PdC96\n\tlec4dBOWPqNeKL/qOAGGXcJ1CMOgmqVO5mOJ3We6FSynIBB0Z+FiBFdHACGNPdF/8m\n\tkwRClwUlDbUg4U5Hm6Cez7ghmb8GwNBtPX44LnvnllQa7AV15WdnvfEYe93cDe0b2i\n\tC1uMXRx8IEZOA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1664246270;\n\tbh=cYsCTrk5122uifEVEu5V4F9/P4MluZ7OC+U6xLpN+uI=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=cubKMqwSV5fL98iiRR+XOsxi2zOe+EM5vebfPEhEA/o/2jBiQJsPGjDhRIwCLPKGY\n\tAYCXAJjMMDr6X2PaZ4F2IUpuyDP2My1Itoyb1/gqwsOjMZQdmrDuRmuNsA0OykEzGr\n\tz82hamIy1r9ilBuAJDkAA9o9e0ge7kTCclHUEMlc="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"cubKMqwS\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 27 Sep 2022 05:36:42 +0300","Message-Id":"<20220927023642.12341-34-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20220927023642.12341-1-laurent.pinchart@ideasonboard.com>","References":"<20220927023642.12341-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 33/33] ipa: rkisp1: awb: Remove bias\n\tfrom 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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The red and blue gains are computed by dividing the green mean by the\nred and blue means respectively. An offset of 1 is added to the dividers\nto avoid divisions by zero. This introduces a bias in the gain values.\nFix it by clamping the divisors to a minimum of 1.0 instead of adding an\noffset.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/awb.cpp | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\nindex 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","prefixes":["libcamera-devel","v5","33/33"]}