[{"id":33803,"web_url":"https://patchwork.libcamera.org/comment/33803/","msgid":"<174344378714.3394313.16154036477841578047@ping.linuxembedded.co.uk>","date":"2025-03-31T17:56:27","subject":"Re: [PATCH v2 16/17] ipa: rkisp1: awb: Take the CCM into account for\n\tthe AWB gains calculation","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-03-19 16:11:21)\n> The AWB measurements are taken after the CCM. This can be seen by\n> enabling debug logging on AWB, disabling AWB (stats will still be\n> processed) and manually chaning the CCM.\n> \n> This means that the estimated colour temperature and the corresponding\n> CCM also lead to changed rgbMeans which in turn leads to oscillations.\n> Fix that by applying the inverse transform on the rgbMeans.\n> \n\nI'm happy to see this one!\n\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> \n> ---\n> \n> Changes in v2:\n> - Improved commit message\n> - Added comment in the code\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 6 ++++++\n>  1 file changed, 6 insertions(+)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index 324bc14b42a0..e8b04d03748d 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -412,6 +412,12 @@ RGB<double> Awb::calculateRgbMeans(const IPAFrameContext &frameContext, const rk\n>                 rgbMeans = rgbMeans.max(0.0);\n>         }\n>  \n> +       /*\n> +        * The ISP computes the AWB means after applying the ccm. Apply the\n> +        * inverse as we want to get the raw means before the colour gains.\n> +        */\n> +       rgbMeans = frameContext.ccm.ccm.inverse() * rgbMeans;\n> +\n\nSo 'simple' yet so powerful thanks to the helpers before.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\nSounds silly, but I would have written this as :\n\n\trgbMeans = rgbMeans * frameContext.ccm.ccm.inverse();\n\nBut I (very much) hope that's identical, but reads as 'multiply the rgb\nby the inverse ccm' to me, (as opposed to 'multiply the inverse CCM by\nthe rgbMeans).\n\nAnyway, it shouldn't make a difference so it's fine either way to me.\n\n\n>         /*\n>          * The ISP computes the AWB means after applying the colour gains,\n>          * divide by the gains that were used to get the raw means from the\n> -- \n> 2.43.0\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 0AFDAC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 31 Mar 2025 17:56:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3111C68985;\n\tMon, 31 Mar 2025 19:56:31 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 371B568967\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 31 Mar 2025 19:56:30 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 74A3A703;\n\tMon, 31 Mar 2025 19:54:38 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"E/+QpwrU\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743443678;\n\tbh=lRBDVlVp118+YGH4CF/CdoRXjSpdu5XhM8a+VFdmsPw=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=E/+QpwrUn4d+ZVoHZb4c8pRP447DLKViLO2o1foT2JAE6oB2n+eiy/EC7zyG8/WDo\n\tdMcoxK6or//UcbzlpOHz1NuJZi9Kg9kUdVv5bYe1W0LPeFQ79lou4qogi/9sm2Psro\n\taquGoGRd8XlSwJvtN207cNjrMduED0YrrdPSAhno=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250319161152.63625-17-stefan.klug@ideasonboard.com>","References":"<20250319161152.63625-1-stefan.klug@ideasonboard.com>\n\t<20250319161152.63625-17-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v2 16/17] ipa: rkisp1: awb: Take the CCM into account for\n\tthe AWB gains calculation","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 31 Mar 2025 18:56:27 +0100","Message-ID":"<174344378714.3394313.16154036477841578047@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":33834,"web_url":"https://patchwork.libcamera.org/comment/33834/","msgid":"<20250401014757.GX14432@pendragon.ideasonboard.com>","date":"2025-04-01T01:47:57","subject":"Re: [PATCH v2 16/17] ipa: rkisp1: awb: Take the CCM into account for\n\tthe AWB gains calculation","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Mon, Mar 31, 2025 at 06:56:27PM +0100, Kieran Bingham wrote:\n> Quoting Stefan Klug (2025-03-19 16:11:21)\n> > The AWB measurements are taken after the CCM. This can be seen by\n> > enabling debug logging on AWB, disabling AWB (stats will still be\n> > processed) and manually chaning the CCM.\n> > \n> > This means that the estimated colour temperature and the corresponding\n> > CCM also lead to changed rgbMeans which in turn leads to oscillations.\n> > Fix that by applying the inverse transform on the rgbMeans.\n> \n> I'm happy to see this one!\n> \n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > \n> > ---\n> > \n> > Changes in v2:\n> > - Improved commit message\n> > - Added comment in the code\n> > ---\n> >  src/ipa/rkisp1/algorithms/awb.cpp | 6 ++++++\n> >  1 file changed, 6 insertions(+)\n> > \n> > diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> > index 324bc14b42a0..e8b04d03748d 100644\n> > --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> > +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> > @@ -412,6 +412,12 @@ RGB<double> Awb::calculateRgbMeans(const IPAFrameContext &frameContext, const rk\n> >                 rgbMeans = rgbMeans.max(0.0);\n> >         }\n> >  \n> > +       /*\n> > +        * The ISP computes the AWB means after applying the ccm. Apply the\n\ns/ccm/CCM/\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> > +        * inverse as we want to get the raw means before the colour gains.\n> > +        */\n> > +       rgbMeans = frameContext.ccm.ccm.inverse() * rgbMeans;\n> > +\n> \n> So 'simple' yet so powerful thanks to the helpers before.\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> \n> Sounds silly, but I would have written this as :\n> \n> \trgbMeans = rgbMeans * frameContext.ccm.ccm.inverse();\n> \n> But I (very much) hope that's identical,\n\nIt's not :-)\n\n> but reads as 'multiply the rgb\n> by the inverse ccm' to me, (as opposed to 'multiply the inverse CCM by\n> the rgbMeans).\n> \n> Anyway, it shouldn't make a difference so it's fine either way to me.\n> \n> >         /*\n> >          * The ISP computes the AWB means after applying the colour gains,\n> >          * divide by the gains that were used to get the raw means from the","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 A6D69C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Apr 2025 01:48:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BD15B6897E;\n\tTue,  1 Apr 2025 03:48:24 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5AA8A62C66\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Apr 2025 03:48:23 +0200 (CEST)","from pendragon.ideasonboard.com (85-76-147-224-nat.elisa-mobile.fi\n\t[85.76.147.224])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D4F1F6F9;\n\tTue,  1 Apr 2025 03:46:30 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"aNgdlLk6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743471991;\n\tbh=qlsDWr3CCLDquCYc0/s8S+iflp9UBdsmIbdsWkOK+DQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=aNgdlLk6de16BrerTcplKRAl2UEihk/7Yieq5SOeUZ636xXVE5zdtBYODDf+m/M3M\n\tWMTzofcTULUioYEzUjSz5YbG80j62kIUJjLzHTSZW/+3UZdlSRO8wKGOQD2YqDzHlc\n\tvcbYxZkYD7YEmC00SdJjjLFk8m7C9h7b1+1TaLNk=","Date":"Tue, 1 Apr 2025 04:47:57 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 16/17] ipa: rkisp1: awb: Take the CCM into account for\n\tthe AWB gains calculation","Message-ID":"<20250401014757.GX14432@pendragon.ideasonboard.com>","References":"<20250319161152.63625-1-stefan.klug@ideasonboard.com>\n\t<20250319161152.63625-17-stefan.klug@ideasonboard.com>\n\t<174344378714.3394313.16154036477841578047@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<174344378714.3394313.16154036477841578047@ping.linuxembedded.co.uk>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]