Patch Detail
Show a patch.
GET /api/patches/18818/?format=api
{ "id": 18818, "url": "https://patchwork.libcamera.org/api/patches/18818/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18818/", "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": "<20230707031702.603261-4-ben.benson@raspberrypi.com>", "date": "2023-07-07T03:17:02", "name": "[libcamera-devel,v2,3/3] utils: raspberrypi: ctt: Code tidying", "commit_ref": "09dd65442b62f4069189f7a92f2b224687257e52", "pull_url": null, "state": "accepted", "archived": false, "hash": "11d082c82a371c8f7b7e7dabac0e13ca418796b8", "submitter": { "id": 171, "url": "https://patchwork.libcamera.org/api/people/171/?format=api", "name": "Ben Benson", "email": "ben.benson@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18818/mbox/", "series": [ { "id": 3969, "url": "https://patchwork.libcamera.org/api/series/3969/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3969", "date": "2023-07-07T03:16:59", "name": "Raspberry Pi Color Matrix and Tuning Tool Improvements", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3969/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18818/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18818/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 0F7CBC3243\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 13 Jul 2023 10:35:25 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A5098628BE;\n\tThu, 13 Jul 2023 12:35:24 +0200 (CEST)", "from mail-wm1-x332.google.com (mail-wm1-x332.google.com\n\t[IPv6:2a00:1450:4864:20::332])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 00EBB628BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Jul 2023 12:35:20 +0200 (CEST)", "by mail-wm1-x332.google.com with SMTP id\n\t5b1f17b1804b1-3fbc59de009so4449075e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Jul 2023 03:35:19 -0700 (PDT)", "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tr8-20020a056000014800b0030fa3567541sm7551143wrx.48.2023.07.13.03.35.18\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 13 Jul 2023 03:35:19 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1689244524;\n\tbh=jw+82qi0/UuzPpsk/6k6piAp+aRX3cyESCpbl+L9cMk=;\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:Cc:\n\tFrom;\n\tb=IBvbIxf8T+2Av3q3r9W62GfHUMHkfhXSdsIn0ovOrK1UV8v/vCEt+WgarWeGI98aQ\n\tGjHRC3d2i0i+32tAAFeDAJrrG8Tvhqx56JKdyK1qlyk+0VK1unc2uzt5h/rOIZzOV/\n\togp0eIlAulRtHNdlw/Hu8V5lBPPpKUwnsG7/N+pPo9CH4mTwDO2aIoG1/uFbW0ypFW\n\tuvuvPN0xtO+ayo1YfMTYf8EYIcbSgnIx52vOsAKoDR9HJ9lNyv5n7mTxSzktxO06Gz\n\tlAtcnZIUEzHcnV8GC5dcXa5/jlrWd2tK0kdD37eY6ozOrR8cQpfO7YEU0pFhIYZUIn\n\t0s05o96Xz497w==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1689244519; x=1691836519;\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=uDUF0jTZCrHu9jkvf3VStWYgCNFIJCcJisHmCTREtxY=;\n\tb=sNkbTw9cHlceE5z9cUiWHPNsARgYKxSjg8EaexuOE5ZCMOb9iX0a5SDAxQPvVQ7y6t\n\thzMSxs8rkcSLoBpcpZMh05l5GOfPNeChSTvkbAk+SiAPchyeD+3hZyM9K+F5jJKVmfqi\n\tXtUJUnBLpF4ENHXPHEShIdKuVHtVcV4PVrnWXMbHzTu+g9ZW1g1WaRHPCtuyD9s6v4Wd\n\tHIm+tE9U8qmXWEqZmbxeUV+VwRQp3cN4UItRrevdjqxjIjt9hEdlkuQ9l3sLTNwC9q9P\n\tF2ydRu8ZvSF5sH5px7AWu+XYhJm1d8Wgv2J+uC5u/dTaFRDsNnEpgvhH+VW9ZdvEvtmX\n\tSEXg==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"sNkbTw9c\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1689244519; x=1691836519;\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=uDUF0jTZCrHu9jkvf3VStWYgCNFIJCcJisHmCTREtxY=;\n\tb=fB4/EVjZpkm/8mDoLqIYBESEz5ywR4x3N025Za0miPBBNHcO5sOvqNwlAF7ZAmhGyo\n\tQDaT12nls6yxOPZ1y3glbyIqlxyIduQMTvEib8yAwwW+8ftKwYBfhZocMxEHm+Ht21wk\n\tC2+pspcBWeZwMH2NEuv4rkYYmm6SjQwyb8NsHOC9VPv2qAP0d+7K9l3eztfeSCzTJsSb\n\t8y4HWaXeZ34mn7ZlTGeNKt82cKp4FeE092WqHWjxgObzIhxySPrd7qRjyK0OHBFP17xu\n\tw96wlFWbL/I/5tY859g6EB97ftbyBWILPdbcGWO6A0e8U3vpJ249XOXnXk9KCVWQqsBa\n\tk5LQ==", "X-Gm-Message-State": "ABy/qLYQkWS7S7OCJj6d71mPqjDpDnKXm0Xdt1A72n2gADWpDRigpmU3\n\tdjWSJE+kU371CyZ0SrriJxYquHkIjGIhDgojwZEOVTmo", "X-Google-Smtp-Source": "APBJJlF/7g/yRz47991wE4qKUA33UGYdJcYKj8Dg4ROpcAkbhP3lVAn3Q89KU7RirjvMWiIgVWTxOA==", "X-Received": "by 2002:a5d:4bc7:0:b0:313:f862:6e3e with SMTP id\n\tl7-20020a5d4bc7000000b00313f8626e3emr1049626wrt.40.1689244519325; \n\tThu, 13 Jul 2023 03:35:19 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 7 Jul 2023 04:17:02 +0100", "Message-Id": "<20230707031702.603261-4-ben.benson@raspberrypi.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20230707031702.603261-1-ben.benson@raspberrypi.com>", "References": "<20230707031702.603261-1-ben.benson@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 3/3] utils: raspberrypi: ctt: Code\n\ttidying", "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": "Ben Benson via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Ben Benson <ben.benson@raspberrypi.com>", "Cc": "Ben Benson <ben.benson@raspberrypi.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Altered the way that some lines are laid out, made functions\nmore attractive to look at, and tidied up messy areas.\n\nSigned-off-by: Ben Benson <ben.benson@raspberrypi.com>\n---\n utils/raspberrypi/ctt/ctt_ccm.py | 61 ++++++++++++++------------------\n 1 file changed, 27 insertions(+), 34 deletions(-)", "diff": "diff --git a/utils/raspberrypi/ctt/ctt_ccm.py b/utils/raspberrypi/ctt/ctt_ccm.py\nindex 49159535..a09bfd09 100644\n--- a/utils/raspberrypi/ctt/ctt_ccm.py\n+++ b/utils/raspberrypi/ctt/ctt_ccm.py\n@@ -47,11 +47,8 @@ def degamma(x):\n \n \n def gamma(x):\n- # return (x * * (1 / 2.4) * 1.055 - 0.055)\n- e = []\n- for i in range(len(x)):\n- e.append(((x[i] / 255) ** (1 / 2.4) * 1.055 - 0.055) * 255)\n- return e\n+ # Take 3 long array of color values and gamma them\n+ return [((colour / 255) ** (1 / 2.4) * 1.055 - 0.055) * 255 for colour in x]\n \n \n \"\"\"\n@@ -96,10 +93,8 @@ def ccm(Cam, cal_cr_list, cal_cb_list):\n \"\"\"\n m_srgb = degamma(m_rgb) # now in 16 bit color.\n \n- m_lab = []\n- for col in m_srgb:\n- m_lab.append(colors.RGB_to_LAB(col / 256))\n- # This produces matrix of LAB values for ideal color chart)\n+ # Produce array of LAB values for ideal color chart\n+ m_lab = [colors.RGB_to_LAB(color / 256) for color in m_srgb]\n \n \"\"\"\n reorder reference values to match how patches are ordered\n@@ -168,7 +163,7 @@ def ccm(Cam, cal_cr_list, cal_cb_list):\n sumde = 0\n ccm = do_ccm(r, g, b, m_srgb)\n # This is the initial guess that our optimisation code works with.\n-\n+ original_ccm = ccm\n r1 = ccm[0]\n r2 = ccm[1]\n g1 = ccm[3]\n@@ -188,7 +183,7 @@ def ccm(Cam, cal_cr_list, cal_cb_list):\n We use our old CCM as the initial guess for the program to find the\n optimised matrix\n '''\n- result = minimize(guess, x0, args=(r, g, b, m_lab), tol=0.0000000001)\n+ result = minimize(guess, x0, args=(r, g, b, m_lab), tol=0.01)\n '''\n This produces a color matrix which has the lowest delta E possible,\n based off the input data. Note it is impossible for this to reach\n@@ -199,12 +194,13 @@ def ccm(Cam, cal_cr_list, cal_cb_list):\n [r1, r2, g1, g2, b1, b2] = result.x\n # The new, optimised color correction matrix values\n optimised_ccm = [r1, r2, (1 - r1 - r2), g1, g2, (1 - g1 - g2), b1, b2, (1 - b1 - b2)]\n+\n # This is the optimised Color Matrix (preserving greys by summing rows up to 1)\n Cam.log += str(optimised_ccm)\n Cam.log += \"\\n Old Color Correction Matrix Below \\n\"\n Cam.log += str(ccm)\n \n- formatted_ccm = np.array(ccm).reshape((3, 3))\n+ formatted_ccm = np.array(original_ccm).reshape((3, 3))\n \n '''\n below is a whole load of code that then applies the latest color\n@@ -213,22 +209,21 @@ def ccm(Cam, cal_cr_list, cal_cb_list):\n '''\n optimised_ccm_rgb = [] # Original Color Corrected Matrix RGB / LAB\n optimised_ccm_lab = []\n- for w in range(24):\n- RGB = np.array([r[w], g[w], b[w]])\n- ccm_applied_rgb = np.dot(formatted_ccm, (RGB / 256))\n- optimised_ccm_rgb.append(gamma(ccm_applied_rgb))\n- optimised_ccm_lab.append(colors.RGB_to_LAB(ccm_applied_rgb))\n \n- formatted_optimised_ccm = np.array(ccm).reshape((3, 3))\n+ formatted_optimised_ccm = np.array(optimised_ccm).reshape((3, 3))\n after_gamma_rgb = []\n after_gamma_lab = []\n- for w in range(24):\n- RGB = np.array([r[w], g[w], b[w]])\n- optimised_ccm_applied_rgb = np.dot(formatted_optimised_ccm, RGB / 256)\n+\n+ for RGB in zip(r, g, b):\n+ ccm_applied_rgb = np.dot(formatted_ccm, (np.array(RGB) / 256))\n+ optimised_ccm_rgb.append(gamma(ccm_applied_rgb))\n+ optimised_ccm_lab.append(colors.RGB_to_LAB(ccm_applied_rgb))\n+\n+ optimised_ccm_applied_rgb = np.dot(formatted_optimised_ccm, np.array(RGB) / 256)\n after_gamma_rgb.append(gamma(optimised_ccm_applied_rgb))\n after_gamma_lab.append(colors.RGB_to_LAB(optimised_ccm_applied_rgb))\n '''\n- Gamma After RGB / LAB\n+ Gamma After RGB / LAB - not used in calculations, only used for visualisation\n We now want to spit out some data that shows\n how the optimisation has improved the color matrices\n '''\n@@ -303,9 +298,8 @@ def guess(x0, r, g, b, m_lab): # provides a method of numerical feedback f\n def transform_and_evaluate(ccm, r, g, b, m_lab): # Transforms colors to LAB and applies the correction matrix\n # create list of matrix changed colors\n realrgb = []\n- for i in range(len(r)):\n- RGB = np.array([r[i], g[i], b[i]])\n- rgb_post_ccm = np.dot(ccm, RGB) # This is RGB values after the color correction matrix has been applied\n+ for RGB in zip(r, g, b):\n+ rgb_post_ccm = np.dot(ccm, np.array(RGB) / 256) # This is RGB values after the color correction matrix has been applied\n realrgb.append(colors.RGB_to_LAB(rgb_post_ccm))\n # now compare that with m_lab and return numeric result, averaged for each patch\n return (sumde(realrgb, m_lab) / 24) # returns an average result of delta E\n@@ -315,12 +309,12 @@ def sumde(listA, listB):\n global typenum, test_patches\n sumde = 0\n maxde = 0\n- patchde = []\n- for i in range(len(listA)):\n- if maxde < (deltae(listA[i], listB[i])):\n- maxde = deltae(listA[i], listB[i])\n- patchde.append(deltae(listA[i], listB[i]))\n- sumde += deltae(listA[i], listB[i])\n+ patchde = [] # Create array of the delta E values for each patch. useful for optimisation of certain patches\n+ for listA_item, listB_item in zip(listA, listB):\n+ if maxde < (deltae(listA_item, listB_item)):\n+ maxde = deltae(listA_item, listB_item)\n+ patchde.append(deltae(listA_item, listB_item))\n+ sumde += deltae(listA_item, listB_item)\n '''\n The different options specified at the start allow for\n the maximum to be returned, average or specific patches\n@@ -330,9 +324,8 @@ def sumde(listA, listB):\n if typenum == 1:\n return maxde\n if typenum == 2:\n- output = 0\n- for y in range(len(test_patches)):\n- output += patchde[test_patches[y]] # grabs the specific patches (no need for averaging here)\n+ output = sum([patchde[test_patch] for test_patch in test_patches])\n+ # Selects only certain patches and returns the output for them\n return output\n \n \n", "prefixes": [ "libcamera-devel", "v2", "3/3" ] }