From patchwork Tue Dec 17 14:59:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 22378 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4F4D4BD1F1 for ; Tue, 17 Dec 2024 15:00:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 558F267FD5; Tue, 17 Dec 2024 16:00:14 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="leG01dPT"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D77F267F0D for ; Tue, 17 Dec 2024 16:00:12 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:1451:ee40:8df6:656d]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 76D763E; Tue, 17 Dec 2024 15:59:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1734447575; bh=g2aGI4gcNdTAnnVy5e3WxZJHshLnJ+V2K65qpbPiUSk=; h=From:To:Cc:Subject:Date:From; b=leG01dPTKTjB5zkZLWgyQd7VyF/7noWnjmcMDecddCwcRNISPdF/l0N3dcrJxO7zg w3luvQv+xsjXGbryJMladlmjbejn0Hx+kWI434MgNc7wr+DlOX5VCVhnnVWDYb4I+A 6oYilAYAwZRPWhvF6uyCQY5JqHtfnnTmW/GBJ/24= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH] utils: tuning: libtuning: Fix tuning for non RGGB RAWs Date: Tue, 17 Dec 2024 15:59:35 +0100 Message-ID: <20241217150007.376357-1-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Tuning fails for raw images that don't have the channels ordered in RGGB. In 19dc8c28f63c ("utils: tuning: libtuning: Implement the core of libtuning") the channels of the image were reordered to RGGB unconditionally in _read_image_dng(). That change was not applied to the ctt_awb code, so that the channels were reordered twice. Fix by removing the double ordering. Signed-off-by: Stefan Klug Tested-by: Isaac Scott Reviewed-by: Isaac Scott Reviewed-by: Laurent Pinchart --- utils/tuning/libtuning/ctt_awb.py | 3 +-- utils/tuning/libtuning/image.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/tuning/libtuning/ctt_awb.py b/utils/tuning/libtuning/ctt_awb.py index 117612f2582a..240f37e644bb 100644 --- a/utils/tuning/libtuning/ctt_awb.py +++ b/utils/tuning/libtuning/ctt_awb.py @@ -302,10 +302,10 @@ def get_alsc_patches(Img, colour_cals, grey=True): patches for each channel, remembering to subtract blacklevel If grey then only greyscale patches considered """ + patches = Img.patches if grey: cen_coords = Img.cen_coords[3::4] col = Img.color - patches = [np.array(Img.patches[i]) for i in Img.order] r_patchs = patches[0][3::4] - Img.blacklevel_16 b_patchs = patches[3][3::4] - Img.blacklevel_16 """ @@ -315,7 +315,6 @@ def get_alsc_patches(Img, colour_cals, grey=True): else: cen_coords = Img.cen_coords col = Img.color - patches = [np.array(Img.patches[i]) for i in Img.order] r_patchs = patches[0] - Img.blacklevel_16 b_patchs = patches[3] - Img.blacklevel_16 g_patchs = (patches[1]+patches[2])/2 - Img.blacklevel_16 diff --git a/utils/tuning/libtuning/image.py b/utils/tuning/libtuning/image.py index c8911a0ff125..ecd334bdc67f 100644 --- a/utils/tuning/libtuning/image.py +++ b/utils/tuning/libtuning/image.py @@ -135,6 +135,6 @@ class Image: all_patches.append(ch_patches) - self.patches = all_patches + self.patches = np.array(all_patches) return not saturated