{"id":23293,"url":"https://patchwork.libcamera.org/api/patches/23293/?format=json","web_url":"https://patchwork.libcamera.org/patch/23293/","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":"<20250428103604.151551-2-david.plowman@raspberrypi.com>","date":"2025-04-28T10:36:03","name":"[1/2] utils: raspberrypi: ctt: Fix NaNs in lens shading tables","commit_ref":"36ba0e5515075f87490048aa1d5f57b6c3864bae","pull_url":null,"state":"accepted","archived":false,"hash":"e5e92574d849143c1c8154697a6d578811d6ffca","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23293/mbox/","series":[{"id":5149,"url":"https://patchwork.libcamera.org/api/series/5149/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5149","date":"2025-04-28T10:36:02","name":"Raspberry Pi Camera Tuning Tool fixes","version":1,"mbox":"https://patchwork.libcamera.org/series/5149/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23293/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23293/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 A1E8AC32A2\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Apr 2025 10:36:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 81FE268AD3;\n\tMon, 28 Apr 2025 12:36:11 +0200 (CEST)","from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com\n\t[IPv6:2a00:1450:4864:20::32c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B028A617E0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Apr 2025 12:36:08 +0200 (CEST)","by mail-wm1-x32c.google.com with SMTP id\n\t5b1f17b1804b1-43cf257158fso26079645e9.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Apr 2025 03:36:08 -0700 (PDT)","from davidp-xps-13.pitowers.org\n\t([2a00:1098:3142:1f:6594:d5bc:c5ae:99b5])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-4408d04802fsm116243185e9.1.2025.04.28.03.36.07\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 28 Apr 2025 03:36:07 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"Koxsizam\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1745836568; x=1746441368;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=qoRCr89TXl/i3hjgdLgcG0kkBisf6Z3KiLiAat5s6SY=;\n\tb=KoxsizamAacy6EB5kZm8sH9fsrK/EL/5/SsgSD4Uhf1Hlah0vgCOgm7/rlA1l/NoyB\n\t3Le2xBAvSkm/o5iHcHnIs5ctWMzyKNgXril7wCMD/pVdZXvSskEuHkBgX8IkY+naZosg\n\t287grTAQbLutlY9r2K+nvuemNnkvZ0hZGeX4N/1PEYMGo+9hRpz2md/lvLrK+pwJJXnP\n\tc/tCUOPoIXxZc9G+e8Rj1s7B6DQD9zewWhBM9V78crXBEej2+SedknvWca0tyWdOKogU\n\tIf8FKxzhJy7O9Ijp4Edw6EXADx0PxDUwleeIRtCW7gIq7jBsIQdAeQqFMiXRMcFG5urv\n\tGmhA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1745836568; x=1746441368;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=qoRCr89TXl/i3hjgdLgcG0kkBisf6Z3KiLiAat5s6SY=;\n\tb=QTt/VJi6WuUD7b1CanoVlzOo5Xu6Hd7agdyYEW0fgYJnlgJb53C5Vk+XJaCOR4xpWL\n\tfiUevx59ru5uzuMBE0hPrZLO+/ae3x0sEAM/TtM4HgfzAPKmZwhvmqhNSf2+MVM5i3ho\n\tC2VIKxK1wi1rkJ5Uu+i9PNGDoe4aUu2OukF7G9oD6Aq2EaL8exrNFW5cTNgE0n66Hmi6\n\taJShMH6H3s5U/o0G9VHKN6dc6kvYEU8ge1w5tpRwEmT2+3yDQArL0dKyJONnKZiJlMsi\n\tnNyjMlaVe71dNCW6I4tMixtyhKBMuIC/+816lKptrh9LWwEj/aNMXs8vPG+GhBKO+Y0t\n\tYXbw==","X-Gm-Message-State":"AOJu0YzrWVgVrAJUHBUH3TNrMM0IEzuXeldsiJUSyxCqYyMsxNdGVibJ\n\tjXnQ/XC1I3DGW5yKWd/SkD/Z4YuLLbuXeuaZuAnzsPwkWkvlCvNZW7w49cxQQ+OgeR94RPajy2s\n\tJ","X-Gm-Gg":"ASbGncsMfJ/SLtxqSg/dZqNvBfxxQwvKqQA5/icovVM5Iq30oUcbNHDcVuQqQXot0kl\n\tdSv3bRbmkApAeRkZXVrb6Xv3defMmfoFp0Xu8A6Bic0j/UAsiYFSs6YcbFSKUU+zs9razKwlKrc\n\tnNH4D/O9tFathSqeAKYHb0XIXW/aCRFPopgdyv+xxYAwFsW6cw0KSEtKRL0g6ivuEVOTycPSJbS\n\tlgHe9HmP0lnNSx70nbeVUnZoKq3ETU1dAD/y4rLy8sqPjMMjJJmdfqIoEn4HxGpyr3MOHLiZjaP\n\tWvTF/Hy04duUeRVxIWQfTChuvJ+pZ6cmn5sN/6pzQT4ty3Bn0a/Yk5y/beLGHcwcChMzCDh9KDb\n\tbwMWXOH0q/w==","X-Google-Smtp-Source":"AGHT+IFeC/Qys+/7sF45M/fkHIF2OL1t5xj5tpFJZ8FW6zvHkojyOSceKkwzXx8Kb5JbkZgkEDBZ5A==","X-Received":"by 2002:a05:600c:a4d:b0:43d:fa58:8377 with SMTP id\n\t5b1f17b1804b1-440ab871ff7mr66062485e9.32.1745836567840; \n\tMon, 28 Apr 2025 03:36:07 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"David Plowman <david.plowman@raspberrypi.com>","Subject":"[PATCH 1/2] utils: raspberrypi: ctt: Fix NaNs in lens shading tables","Date":"Mon, 28 Apr 2025 11:36:03 +0100","Message-Id":"<20250428103604.151551-2-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20250428103604.151551-1-david.plowman@raspberrypi.com>","References":"<20250428103604.151551-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>"},"content":"The problem occurs when the calculation could lead to a final row (or\ncolumn) of grid squares with no pixels in them (and hence, NaNs).\n\nOne specific case is a Pi 5 with an image width (or height) of 1364,\nso that's 682 Bayer quads. To give 32 grid squares it was calculating\n22 quads per cell. However, 31 * 22 = 682 leaving nothing in the final\ncolumn.\n\nThe fix is to do a rounding-down division by the number of cells minus\none, rather than a rounding-up division by the number of cells. This\nturns the corner case from one where the final row/column has no\npixels to one where we don't quite cover the full image, which is how\nwe have to handle these cases.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n utils/raspberrypi/ctt/ctt_alsc.py | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)","diff":"diff --git a/utils/raspberrypi/ctt/ctt_alsc.py b/utils/raspberrypi/ctt/ctt_alsc.py\nindex 1d94dfa5..f4fd09e3 100644\n--- a/utils/raspberrypi/ctt/ctt_alsc.py\n+++ b/utils/raspberrypi/ctt/ctt_alsc.py\n@@ -127,11 +127,12 @@ def alsc(Cam, Img, do_alsc_colour, plot=False, grid_size=(16, 12), max_gain=8.0)\n     channels = [Img.channels[i] for i in Img.order]\n     \"\"\"\n     calculate size of single rectangle.\n-    -(-(w-1)//32) is a ceiling division. w-1 is to deal robustly with the case\n-    where w is a multiple of 32.\n+    The divisions here must ensure the final row/column of cells has a non-zero number of\n+    pixels.\n     \"\"\"\n     w, h = Img.w/2, Img.h/2\n-    dx, dy = int(-(-(w-1)//grid_w)), int(-(-(h-1)//grid_h))\n+    dx, dy = (w - 1) // (grid_w - 1), (h - 1) // (grid_h - 1)\n+\n     \"\"\"\n     average the green channels into one\n     \"\"\"\n","prefixes":["1/2"]}