Show a patch.

GET /api/patches/17653/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 17653,
    "url": "https://patchwork.libcamera.org/api/patches/17653/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17653/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20221022062310.2545463-3-paul.elder@ideasonboard.com>",
    "date": "2022-10-22T06:23:01",
    "name": "[libcamera-devel,v2,02/11] utils: libtuning: modules: Add ALSC module",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "7dd842afc75a5b8a74fff6772d23c21449c27ff6",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/17653/mbox/",
    "series": [
        {
            "id": 3573,
            "url": "https://patchwork.libcamera.org/api/series/3573/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3573",
            "date": "2022-10-22T06:22:59",
            "name": "utils: tuning: Add a new tuning infrastructure",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/3573/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17653/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17653/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 059D0C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 22 Oct 2022 06:23:29 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B571362ED0;\n\tSat, 22 Oct 2022 08:23:28 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C2A6F62EC3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 22 Oct 2022 08:23:24 +0200 (CEST)",
            "from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 67F25106;\n\tSat, 22 Oct 2022 08:23:23 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666419808;\n\tbh=sjsrLUhf4WlqMjHRF76GfAgAS7z1irWu2Vo1Lwc5b0c=;\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=4Zs0X7MFECamDD10UpDBnKmzy0nvp8vQUCOaH8sAEpP0WIggPD5gjGn0BWAdoKaqi\n\teoXYRVTboj1U/JI34k5YZYVmWdZk0H7/j0V1jwXeuo+zsHAqKX2i/hIiuln5auRvDB\n\tB1d1PvmDxXqsA1yO8HjiThBG3vxYY1aNOuD6AGKYpeoatVMa5SFTuQhYZCcaOb4x5n\n\t7nRbTthqK+0TbYmTO4OmOcJ4n6atPznmAnvkGB/t+tWBLdynKx6Bsor1HeIx8whV7H\n\tBJ9bHFN9xwHIdI8dbYBVoAMnCEQAFzyo+eqHT98rl+eAiQn9MSTFegwMeiJGwRF2Nx\n\tIj8Tg5l3XqeOQ==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1666419804;\n\tbh=sjsrLUhf4WlqMjHRF76GfAgAS7z1irWu2Vo1Lwc5b0c=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=hN1386eWkTea7lEWuBiSD9BaBIkzSBZMF7otHylqSXKTow1b2Gx2ArtRpiB16O2YY\n\tk3ifk6eglDu5awg6tmnX57ESfapS6WGmiBFf9z1FAmDt6ikBeS9h/dE8d/sQfgwrAm\n\t3j1HA9j+ZY6fSk23qvNAiOgZscTo86k8R2Pyyhrs="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"hN1386eW\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 22 Oct 2022 15:23:01 +0900",
        "Message-Id": "<20221022062310.2545463-3-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20221022062310.2545463-1-paul.elder@ideasonboard.com>",
        "References": "<20221022062310.2545463-1-paul.elder@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 02/11] utils: libtuning: modules: Add\n\tALSC module",
        "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 an ALSC module to libtuning's collection of modules. It is based on\nraspberrypi's ctt's ALSC, but customizable for different lens shading\ntable sizes, among other things.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges in v2:\n- fix python errors\n- fix style\n- add SPDX and copyright\n- don't call super().validateConfig()\n- fix sector splitting\n  - i forgot that we have to half the image size for each color channel\n- make the base ALSC module into an abstract module, which can be easily\n  used by other platforms to derive their own ALSC modules (see rkisp1's\n  module later in this series; i think it's quite nice)\n---\n .../tuning/libtuning/modules/alsc/__init__.py |  5 ++\n utils/tuning/libtuning/modules/alsc/alsc.py   | 78 +++++++++++++++++++\n 2 files changed, 83 insertions(+)\n create mode 100644 utils/tuning/libtuning/modules/alsc/__init__.py\n create mode 100644 utils/tuning/libtuning/modules/alsc/alsc.py",
    "diff": "diff --git a/utils/tuning/libtuning/modules/alsc/__init__.py b/utils/tuning/libtuning/modules/alsc/__init__.py\nnew file mode 100644\nindex 00000000..a8f28923\n--- /dev/null\n+++ b/utils/tuning/libtuning/modules/alsc/__init__.py\n@@ -0,0 +1,5 @@\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+#\n+# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>\n+\n+from libtuning.modules.alsc.alsc import ALSC\ndiff --git a/utils/tuning/libtuning/modules/alsc/alsc.py b/utils/tuning/libtuning/modules/alsc/alsc.py\nnew file mode 100644\nindex 00000000..b708b28d\n--- /dev/null\n+++ b/utils/tuning/libtuning/modules/alsc/alsc.py\n@@ -0,0 +1,78 @@\n+# SPDX-License-Identifier: BSD-2-Clause\n+#\n+# Copyright (C) 2019, Raspberry Pi Ltd\n+# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>\n+\n+from ..module import Module\n+\n+import libtuning as lt\n+import libtuning.utils as utils\n+\n+import numpy as np\n+\n+\n+class ALSC(Module):\n+    type = 'alsc'\n+    hr_name = 'ALSC (Base)'\n+    out_name = 'GenericALSC'\n+\n+    def __init__(self, *,\n+                 debug: list,\n+                 sector_shape: tuple,\n+                 sector_x_gradient: lt.Gradient,\n+                 sector_y_gradient: lt.Gradient,\n+                 sector_average_function: lt.Average,\n+                 smoothing_function: lt.Smoothing):\n+        super().__init__()\n+\n+        if (sector_x_gradient is lt.gradient.Linear and sector_x_remainder is None):\n+            raise ValueError('sector_x_remainder must be specified if sector_x_gradient is Linear')\n+\n+        if (sector_y_gradient is lt.gradient.Linear and sector_y_remainder is None):\n+            raise ValueError('sector_y_remainder must be specified if sector_y_gradient is Linear')\n+\n+        self.debug = debug\n+\n+        self.sector_shape = sector_shape\n+        self.sector_x_gradient = sector_x_gradient\n+        self.sector_y_gradient = sector_y_gradient\n+        self.sector_average_function = sector_average_function\n+\n+        self.smoothing_function = smoothing_function\n+\n+    def _enumerate_alsc_images(self, images):\n+        for image in images:\n+            if image.alsc_only:\n+                yield image\n+\n+    def _get_grid(self, channel, img_w, img_h):\n+        # List of number of pixels in each sector\n+        sectors_x = self.sector_x_gradient.distribute(img_w / 2, self.sector_shape[0])\n+        sectors_y = self.sector_y_gradient.distribute(img_h / 2, self.sector_shape[1])\n+\n+        grid = []\n+\n+        r = 0\n+        for y in sectors_y:\n+            c = 0\n+            for x in sectors_x:\n+                grid.append(self.sector_average_function.average(channel[r:r + y, c:c + x]))\n+                c += x\n+            r += y\n+\n+        return np.array(grid)\n+\n+    def _lsc_single_channel(self, channel: np.array,\n+                            image: lt.Image, green_grid: np.array = None):\n+        grid = self._get_grid(channel, image.w, image.h)\n+        grid -= image.blacklevel_16\n+        if green_grid is None:\n+            table = np.reshape(1 / grid, self.sector_shape[::-1])\n+        else:\n+            table = np.reshape(green_grid / grid, self.sector_shape[::-1])\n+        table = self.smoothing_function.smoothing(table)\n+\n+        if green_grid is None:\n+            table = table / np.min(table)\n+\n+        return table, grid\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "02/11"
    ]
}