From patchwork Thu Nov 24 11:38:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17881 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 C2110BE08B for ; Thu, 24 Nov 2022 11:39:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0B9D26331A; Thu, 24 Nov 2022 12:39:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669289945; bh=Z/yJL/95+L0S96C27txC4U2nwa7r5KzEKzQv4GvU1YQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=zDfxMCtexbg3wf504VLtkMTTGRbi+GLGo6+09/YyM7Q31nXDptgFnmhvLYqK3Y6Nb e6ExaWE4aCRd8BRa52jEiEiz1fhVcHxtpvHCBmnmie2T3U0N57TZos5aNcut660WcY wMV2zL4nVxdN5HoXImp/XBAJp9HvF/YU/w6Q+Y0XZfk4/x+3lt+vnSVHubYmVoaNrU QGNAK1n++iol9RqJXlr/g/xL3B4zlOCTdNvcuftYpiu4KuOCtNW3Mkm9vokNzM12HZ AlH2W0YyX91qyzkG/pj0KAeCHFJjWGjjxMQeQtAThQT7MpWXhJuck+Mwc6bYekAZ96 xoyxcpjAkCdmQ== 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 D976C632EA for ; Thu, 24 Nov 2022 12:39:03 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VJiFhVfM"; dkim-atps=neutral Received: from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A30CB496; Thu, 24 Nov 2022 12:39:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669289943; bh=Z/yJL/95+L0S96C27txC4U2nwa7r5KzEKzQv4GvU1YQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VJiFhVfMwDtW3qRv5TB6JLzzZAhBgbKR1lHVl+F9EPveFNG7pYE4S2z6mV2zAwCni Wa/npr4rSgPfPmINmb63GVvuqR/7SDIxmrY3voqQ+Pm1Fb0O+VqagKeAHdTCp1DMoV sBqvnkxkvvi9Zy2HRU3QexS/3E2IRL2ibymaJcQA= To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Nov 2022 20:38:45 +0900 Message-Id: <20221124113849.2193579-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221124113849.2193579-1-paul.elder@ideasonboard.com> References: <20221124113849.2193579-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/6] utils: libtuning: modules: lsc: Add debug plot function 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: , X-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a helper function to the base LSC class for plotting an LSC table. This will be used by LSC specializations for debugging pruposes. Signed-off-by: Paul Elder --- utils/tuning/libtuning/modules/lsc/lsc.py | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/utils/tuning/libtuning/modules/lsc/lsc.py b/utils/tuning/libtuning/modules/lsc/lsc.py index f54ca8be..4d580ad4 100644 --- a/utils/tuning/libtuning/modules/lsc/lsc.py +++ b/utils/tuning/libtuning/modules/lsc/lsc.py @@ -8,7 +8,10 @@ from ..module import Module import libtuning as lt import libtuning.utils as utils +import matplotlib.pyplot as plt +from matplotlib import cm import numpy as np +from pathlib import Path class LSC(Module): @@ -67,3 +70,31 @@ class LSC(Module): table = table / np.min(table) return table, grid + + def _plot_single_lsc(self, image: lt.Image, cr: np.array, cb: np.array, + cg1: np.array, cg2: np.array = None): + hf = plt.figure(figsize=(8, 8)) + # Y is plotted as -Y so plot has same axes as image + X, Y = np.meshgrid(range(self.sector_shape[0]), range(self.sector_shape[1])) + + ha = hf.add_subplot(221 if cg2 is not None else 311, projection='3d') + ha.plot_surface(X, -Y, cr, cmap=cm.coolwarm, linewidth=0) + ha.set_title(f'{self.hr_name} Plot\nImage: {image.name}\n\ncr') + + hb = hf.add_subplot(222 if cg2 is not None else 312, projection='3d') + hb.plot_surface(X, -Y, cb, cmap=cm.coolwarm, linewidth=0) + hb.set_title('cb') + + hc = hf.add_subplot(223 if cg2 is not None else 313, projection='3d') + hc.plot_surface(X, -Y, cg1, cmap=cm.coolwarm, linewidth=0) + hc.set_title('gr' if cg2 is not None else 'g') + + if cg2 is not None: + hd = hf.add_subplot(224, projection='3d') + hd.plot_surface(X, -Y, cg2, cmap=cm.coolwarm, linewidth=0) + hd.set_title('gb') + + # The caller will validate self.debug (there's no sense in calling this + # function if self.debug is None anyway) + fname = self.debug / f"{image.name.split('.')[0]}-lsc.png" + plt.savefig(fname)