[{"id":32818,"web_url":"https://patchwork.libcamera.org/comment/32818/","msgid":"<06f25a4e64301565996569d6a05f8497008b8182.camel@ideasonboard.com>","date":"2024-12-17T15:34:58","subject":"Re: [PATCH] utils: tuning: libtuning: Fix tuning for non RGGB RAWs","submitter":{"id":215,"url":"https://patchwork.libcamera.org/api/people/215/","name":"Isaac Scott","email":"isaac.scott@ideasonboard.com"},"content":"Hi Stefan,\n\nThanks for getting this working!\n\nTested on OV8858.\n\nTested-by: Isaac Scott <isaac.scott@ideasonboard.com>\n\nOn Tue, 2024-12-17 at 15:59 +0100, Stefan Klug wrote:\n> Tuning fails for raw images that don't have the channels ordered in\n> RGGB.  In 19dc8c28f63c (\"utils: tuning: libtuning: Implement the core\n> of\n> libtuning\") the channels of the image were reordered to RGGB\n> unconditionally in _read_image_dng(). That change was not applied to\n> the\n> ctt_awb code, so that the channels were reordered twice. Fix by\n> removing\n> the double ordering.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  utils/tuning/libtuning/ctt_awb.py | 3 +--\n>  utils/tuning/libtuning/image.py   | 2 +-\n>  2 files changed, 2 insertions(+), 3 deletions(-)\n> \n> diff --git a/utils/tuning/libtuning/ctt_awb.py\n> b/utils/tuning/libtuning/ctt_awb.py\n> index 117612f2582a..240f37e644bb 100644\n> --- a/utils/tuning/libtuning/ctt_awb.py\n> +++ b/utils/tuning/libtuning/ctt_awb.py\n> @@ -302,10 +302,10 @@ def get_alsc_patches(Img, colour_cals,\n> grey=True):\n>      patches for each channel, remembering to subtract blacklevel\n>      If grey then only greyscale patches considered\n>      \"\"\"\n> +    patches = Img.patches\n>      if grey:\n>          cen_coords = Img.cen_coords[3::4]\n>          col = Img.color\n> -        patches = [np.array(Img.patches[i]) for i in Img.order]\n>          r_patchs = patches[0][3::4] - Img.blacklevel_16\n>          b_patchs = patches[3][3::4] - Img.blacklevel_16\n>          \"\"\"\n> @@ -315,7 +315,6 @@ def get_alsc_patches(Img, colour_cals,\n> grey=True):\n>      else:\n>          cen_coords = Img.cen_coords\n>          col = Img.color\n> -        patches = [np.array(Img.patches[i]) for i in Img.order]\n>          r_patchs = patches[0] - Img.blacklevel_16\n>          b_patchs = patches[3] - Img.blacklevel_16\n>          g_patchs = (patches[1]+patches[2])/2 - Img.blacklevel_16\n> diff --git a/utils/tuning/libtuning/image.py\n> b/utils/tuning/libtuning/image.py\n> index c8911a0ff125..ecd334bdc67f 100644\n> --- a/utils/tuning/libtuning/image.py\n> +++ b/utils/tuning/libtuning/image.py\n> @@ -135,6 +135,6 @@ class Image:\n>  \n>              all_patches.append(ch_patches)\n>  \n> -        self.patches = all_patches\n> +        self.patches = np.array(all_patches)\n>  \n>          return not saturated\n\nReviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>\n\nBest wishes,\nIsaac","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 06E78BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 17 Dec 2024 15:35:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6C29167FDC;\n\tTue, 17 Dec 2024 16:35:03 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E7CDB67FD6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 17 Dec 2024 16:35:01 +0100 (CET)","from isaac-ThinkPad-T16-Gen-2.lan\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 6AE4D3E;\n\tTue, 17 Dec 2024 16:34:24 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Hg2P2TfR\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1734449664;\n\tbh=n0cQwiMrcjY1XDn4Em9Yp7tpJTg/gDfJo/doG99Kqkc=;\n\th=Subject:From:To:Date:In-Reply-To:References:From;\n\tb=Hg2P2TfRKjCuJSOWtfxbURTbS7qXgKut7U/ugXAcRfiLcX2TDRHf2FrHXLjAEB2Rj\n\t7YWhXd357SR4DNHbvzxL03ZPxVz0oMJ3Mf7UGI01U4RIffVlHcjVnnICji4YLE/ebe\n\twbp5DGRanGzUJRI4WNu+zEk/quIXmYcmTTICsNz4=","Message-ID":"<06f25a4e64301565996569d6a05f8497008b8182.camel@ideasonboard.com>","Subject":"Re: [PATCH] utils: tuning: libtuning: Fix tuning for non RGGB RAWs","From":"Isaac Scott <isaac.scott@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>, \n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 17 Dec 2024 15:34:58 +0000","In-Reply-To":"<20241217150007.376357-1-stefan.klug@ideasonboard.com>","References":"<20241217150007.376357-1-stefan.klug@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","User-Agent":"Evolution 3.54.2 (by Flathub.org) ","MIME-Version":"1.0","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":32819,"web_url":"https://patchwork.libcamera.org/comment/32819/","msgid":"<20241217154155.GB20432@pendragon.ideasonboard.com>","date":"2024-12-17T15:41:55","subject":"Re: [PATCH] utils: tuning: libtuning: Fix tuning for non RGGB RAWs","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Tue, Dec 17, 2024 at 03:59:35PM +0100, Stefan Klug wrote:\n> Tuning fails for raw images that don't have the channels ordered in\n> RGGB.  In 19dc8c28f63c (\"utils: tuning: libtuning: Implement the core of\n> libtuning\") the channels of the image were reordered to RGGB\n> unconditionally in _read_image_dng(). That change was not applied to the\n> ctt_awb code, so that the channels were reordered twice. Fix by removing\n> the double ordering.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  utils/tuning/libtuning/ctt_awb.py | 3 +--\n>  utils/tuning/libtuning/image.py   | 2 +-\n>  2 files changed, 2 insertions(+), 3 deletions(-)\n> \n> diff --git a/utils/tuning/libtuning/ctt_awb.py b/utils/tuning/libtuning/ctt_awb.py\n> index 117612f2582a..240f37e644bb 100644\n> --- a/utils/tuning/libtuning/ctt_awb.py\n> +++ b/utils/tuning/libtuning/ctt_awb.py\n> @@ -302,10 +302,10 @@ def get_alsc_patches(Img, colour_cals, grey=True):\n>      patches for each channel, remembering to subtract blacklevel\n>      If grey then only greyscale patches considered\n>      \"\"\"\n> +    patches = Img.patches\n>      if grey:\n>          cen_coords = Img.cen_coords[3::4]\n>          col = Img.color\n> -        patches = [np.array(Img.patches[i]) for i in Img.order]\n>          r_patchs = patches[0][3::4] - Img.blacklevel_16\n>          b_patchs = patches[3][3::4] - Img.blacklevel_16\n>          \"\"\"\n> @@ -315,7 +315,6 @@ def get_alsc_patches(Img, colour_cals, grey=True):\n>      else:\n>          cen_coords = Img.cen_coords\n>          col = Img.color\n> -        patches = [np.array(Img.patches[i]) for i in Img.order]\n>          r_patchs = patches[0] - Img.blacklevel_16\n>          b_patchs = patches[3] - Img.blacklevel_16\n>          g_patchs = (patches[1]+patches[2])/2 - Img.blacklevel_16\n> diff --git a/utils/tuning/libtuning/image.py b/utils/tuning/libtuning/image.py\n> index c8911a0ff125..ecd334bdc67f 100644\n> --- a/utils/tuning/libtuning/image.py\n> +++ b/utils/tuning/libtuning/image.py\n> @@ -135,6 +135,6 @@ class Image:\n>  \n>              all_patches.append(ch_patches)\n>  \n> -        self.patches = all_patches\n> +        self.patches = np.array(all_patches)\n>  \n>          return not saturated","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 3365EC32F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 17 Dec 2024 15:42:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7673967FDE;\n\tTue, 17 Dec 2024 16:41:59 +0100 (CET)","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 B354667FD6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 17 Dec 2024 16:41:57 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 36FAA3E;\n\tTue, 17 Dec 2024 16:41:20 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"oUpQxSTL\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1734450080;\n\tbh=CS2CrkPdq9mYuzJxBYQe3l9eGHNpXWkw0UJouSAV/MU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=oUpQxSTLeJi3Kz+TdttzSnCEM2Kig9Uu1OzUaOBJo6cCvVtPGC/WTUHp5ztQRm7tX\n\tOL3jRsRd3DCrDtWA7UtRbtQyeA0D0TECjpxTya03G80c1+jSpm7i5dqXfvKa5RXIXZ\n\tmPq/5z7G1Dx3VDH23gPBPKnRtwwxaQVtI8jhahtg=","Date":"Tue, 17 Dec 2024 17:41:55 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] utils: tuning: libtuning: Fix tuning for non RGGB RAWs","Message-ID":"<20241217154155.GB20432@pendragon.ideasonboard.com>","References":"<20241217150007.376357-1-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20241217150007.376357-1-stefan.klug@ideasonboard.com>","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>"}}]