{"id":17881,"url":"https://patchwork.libcamera.org/api/patches/17881/?format=json","web_url":"https://patchwork.libcamera.org/patch/17881/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20221124113849.2193579-3-paul.elder@ideasonboard.com>","date":"2022-11-24T11:38:45","name":"[libcamera-devel,2/6] utils: libtuning: modules: lsc: Add debug plot function","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"19f9fa9b7b25b1c5512647c8d3e33458870f9bbf","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17881/mbox/","series":[{"id":3637,"url":"https://patchwork.libcamera.org/api/series/3637/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3637","date":"2022-11-24T11:38:43","name":"utils: tuning: Add per-module debugging","version":1,"mbox":"https://patchwork.libcamera.org/series/3637/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17881/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17881/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 C2110BE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Nov 2022 11:39:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0B9D26331A;\n\tThu, 24 Nov 2022 12:39:05 +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 D976C632EA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Nov 2022 12:39:03 +0100 (CET)","from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A30CB496;\n\tThu, 24 Nov 2022 12:39:02 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669289945;\n\tbh=Z/yJL/95+L0S96C27txC4U2nwa7r5KzEKzQv4GvU1YQ=;\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=zDfxMCtexbg3wf504VLtkMTTGRbi+GLGo6+09/YyM7Q31nXDptgFnmhvLYqK3Y6Nb\n\te6ExaWE4aCRd8BRa52jEiEiz1fhVcHxtpvHCBmnmie2T3U0N57TZos5aNcut660WcY\n\twMV2zL4nVxdN5HoXImp/XBAJp9HvF/YU/w6Q+Y0XZfk4/x+3lt+vnSVHubYmVoaNrU\n\tQGNAK1n++iol9RqJXlr/g/xL3B4zlOCTdNvcuftYpiu4KuOCtNW3Mkm9vokNzM12HZ\n\tAlH2W0YyX91qyzkG/pj0KAeCHFJjWGjjxMQeQtAThQT7MpWXhJuck+Mwc6bYekAZ96\n\txoyxcpjAkCdmQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1669289943;\n\tbh=Z/yJL/95+L0S96C27txC4U2nwa7r5KzEKzQv4GvU1YQ=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=VJiFhVfMwDtW3qRv5TB6JLzzZAhBgbKR1lHVl+F9EPveFNG7pYE4S2z6mV2zAwCni\n\tWa/npr4rSgPfPmINmb63GVvuqR/7SDIxmrY3voqQ+Pm1Fb0O+VqagKeAHdTCp1DMoV\n\tsBqvnkxkvvi9Zy2HRU3QexS/3E2IRL2ibymaJcQA="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"VJiFhVfM\"; dkim-atps=neutral","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 2/6] utils: libtuning: modules: lsc: Add\n\tdebug plot function","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":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Paul Elder <paul.elder@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add a helper function to the base LSC class for plotting an LSC table.\nThis will be used by LSC specializations for debugging pruposes.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n utils/tuning/libtuning/modules/lsc/lsc.py | 31 +++++++++++++++++++++++\n 1 file changed, 31 insertions(+)","diff":"diff --git a/utils/tuning/libtuning/modules/lsc/lsc.py b/utils/tuning/libtuning/modules/lsc/lsc.py\nindex f54ca8be..4d580ad4 100644\n--- a/utils/tuning/libtuning/modules/lsc/lsc.py\n+++ b/utils/tuning/libtuning/modules/lsc/lsc.py\n@@ -8,7 +8,10 @@ from ..module import Module\n import libtuning as lt\n import libtuning.utils as utils\n \n+import matplotlib.pyplot as plt\n+from matplotlib import cm\n import numpy as np\n+from pathlib import Path\n \n \n class LSC(Module):\n@@ -67,3 +70,31 @@ class LSC(Module):\n             table = table / np.min(table)\n \n         return table, grid\n+\n+    def _plot_single_lsc(self, image: lt.Image, cr: np.array, cb: np.array,\n+                         cg1: np.array, cg2: np.array = None):\n+        hf = plt.figure(figsize=(8, 8))\n+        # Y is plotted as -Y so plot has same axes as image\n+        X, Y = np.meshgrid(range(self.sector_shape[0]), range(self.sector_shape[1]))\n+\n+        ha = hf.add_subplot(221 if cg2 is not None else 311, projection='3d')\n+        ha.plot_surface(X, -Y, cr, cmap=cm.coolwarm, linewidth=0)\n+        ha.set_title(f'{self.hr_name} Plot\\nImage: {image.name}\\n\\ncr')\n+\n+        hb = hf.add_subplot(222 if cg2 is not None else 312, projection='3d')\n+        hb.plot_surface(X, -Y, cb, cmap=cm.coolwarm, linewidth=0)\n+        hb.set_title('cb')\n+\n+        hc = hf.add_subplot(223 if cg2 is not None else 313, projection='3d')\n+        hc.plot_surface(X, -Y, cg1, cmap=cm.coolwarm, linewidth=0)\n+        hc.set_title('gr' if cg2 is not None else 'g')\n+\n+        if cg2 is not None:\n+            hd = hf.add_subplot(224, projection='3d')\n+            hd.plot_surface(X, -Y, cg2, cmap=cm.coolwarm, linewidth=0)\n+            hd.set_title('gb')\n+\n+        # The caller will validate self.debug (there's no sense in calling this\n+        # function if self.debug is None anyway)\n+        fname = self.debug / f\"{image.name.split('.')[0]}-lsc.png\"\n+        plt.savefig(fname)\n","prefixes":["libcamera-devel","2/6"]}