[{"id":27514,"web_url":"https://patchwork.libcamera.org/comment/27514/","msgid":"<CAHW6GYLmiJQJPMP_7qDbwef84rePiwmxbD+_HARtBhQGmPHQPw@mail.gmail.com>","date":"2023-07-10T10:25:38","subject":"Re: [libcamera-devel] [PATCH 3/3] utils: raspberrypi: ctt: Code\n\ttidying","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Ben\n\nThanks for the patch!\n\nOn Fri, 7 Jul 2023 at 14:41, Ben Benson via libcamera-devel\n<libcamera-devel@lists.libcamera.org> wrote:\n>\n> Altered the way that some lines are laid out, made functions\n> more attractive to look at, and tidied up messy areas.\n>\n> Signed-off-by Ben Benson <ben.benson@raspberrypi.com>\n\ns/by/by:/\n\nApart from that a couple of very minor observations but which I'm not\ntoo bothered about.\n\nFor future reference, I think we normally fix style issues in the\ncommit where the new code was introduced (if in the same patch\nseries), but I'm inclined not to worry for the moment. (Others may\ndiffer, of course!)\n\nThanks!\nDavid\n\n> ---\n>  utils/raspberrypi/ctt/ctt_ccm.py | 61 +++++++++++++++-----------------\n>  1 file changed, 29 insertions(+), 32 deletions(-)\n>\n> diff --git a/utils/raspberrypi/ctt/ctt_ccm.py b/utils/raspberrypi/ctt/ctt_ccm.py\n> index bd44b4d8..85ca6827 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> +    m_lab = [colors.RGB_to_LAB(color / 256) for color in m_srgb]\n> +    # This produces array of LAB values for ideal color chart)\n\nI think normally we put the comment on the line above the code it applies to.\n\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> @@ -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,23 @@ 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>          after_gamma_rgb = []\n>          after_gamma_lab = []\n> -        for w in range(24):\n> -            RGB = np.array([r[w], g[w], b[w]])\n> +\n> +        for red, green, blue in zip(r, g, b):\n\nI wonder if \"for RGB in zip(r, g, b):\" would work (making the next\nline redundant)?\n\n> +            RGB = np.array([red, green, blue])\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>              optimised_ccm_applied_rgb = np.dot(formatted_optimised_ccm, 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>          '''\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 matricies\n>          '''\n> @@ -303,8 +300,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> +    for red, green, blue in zip(r, g, b):\n> +        RGB = np.array([red, green, blue])\n>          rgb_post_ccm = np.dot(ccm, RGB)  # 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> @@ -315,12 +312,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 +327,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> @@ -341,8 +337,9 @@ calculates the ccm for an individual image.\n>  ccms are calculate in rgb space, and are fit by hand. Although it is a 3x3\n>  matrix, each row must add up to 1 in order to conserve greyness, simplifying\n>  calculation.\n> -Should you want to fit them in another space (e.g. LAB) we wish you the best of\n> -luck and send us the code when you are done! :-)\n> +The initial CCM is calculated in RGB, and then optimised in LAB color space\n> +This simplifies the initial calculation but then gets us the accuracy of\n> +using LAB color space.\n>  \"\"\"\n>\n>\n> --\n> 2.34.1\n>","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 661D2C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 10 Jul 2023 10:25:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C6369628C1;\n\tMon, 10 Jul 2023 12:25:52 +0200 (CEST)","from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com\n\t[IPv6:2607:f8b0:4864:20::72d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 95B1061E31\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 10 Jul 2023 12:25:50 +0200 (CEST)","by mail-qk1-x72d.google.com with SMTP id\n\taf79cd13be357-76754b9eac0so417229785a.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 10 Jul 2023 03:25:50 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1688984752;\n\tbh=5SBnlMSjwXsjkVDrzhqKANiyFt9TL1fZX2J2rJ3fjlk=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=ZSwlXEEK92iDGB5WYu4bdC3V99IZyZ+w8fR8zX3LD+l8TvmexKXnjj1o2Ca5SZtr9\n\tCNP4KCm1kO/VrafUBn3duzNcyHxsVcr5uMjzwhe4jFw2ev4TE1AAKmQSV1T4a1/RCs\n\t5IKc19ivWEXWIxIUxl7S3luD3gnu/aqBYAX9kJXYxpK43RqQOT2ZhUX7wG3YC31oq+\n\t3aKCOtMqmMeTT64pa078WsSWWNytdNF/gHn2wdWYO2dE2l22hx0Y9tW+FpRvmhYcqI\n\tEofbY7nyWytEe8ySQKD2OWJtB4t3bEJpnOaMAiiG4y+C0i7u1M7JCfUTW5pMbP6bfO\n\tgvbYHeqJrL4YA==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1688984749; x=1691576749;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=PNtidBxMHxAFOXJIL2j3nbfo57iUEesHMxTopdl9s+Q=;\n\tb=C/4TQFOM6LBASZRMO6j5MGx5orBGiy0Ya76t0sPJasQJF6CmzPj0cHD+q8iIdg3gLq\n\tZ984y149CX0rqxqJqynwO1OH2pWfnc1S8/CiFThgLyCfRSHXN/BjYEvrRjtWHqT3ZsR4\n\tfE43HNGOiiWIr6HPVrRiPuGXT9getl/GkeVi63u4/ZDfe1qQwPSWtwlc5FaVlBUzfi8S\n\tuwuBwzi0iAmG1py+sg9tMgdKUw1SDqOHOUHiEWthAdWMTV5iBRPUErITGs1nEmC6FSkI\n\tdxAPL94qyT/OcdgNvSAzkwvncIxcM5RkhRUmWSfRKaMIQq7ftazMvseDpBWBDhi1YohQ\n\tHoew=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"C/4TQFOM\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1688984749; x=1691576749;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=PNtidBxMHxAFOXJIL2j3nbfo57iUEesHMxTopdl9s+Q=;\n\tb=TVJwY4Bv/p8teM22RoKmyHZ1pD7Uy+zI1URwKAYDJXmwf0+1Be90zUfsG3HjOeQglg\n\t158Tv5k9iVAF3Q1lSsFRwdVgzAfHSc/W32Zs2g1ZbBVF/0CvHhBf85ISC3gHjQGMXUPx\n\tn+zzBJWsV7RNQbJ4D5Nw3CmNmjBZ/YRO8VXpuuUqoUxOh6/uqpqMWv0fjLoSd/v7pnyC\n\tJufwsr0aUjWLVEqVVoNcX3TxPzY/Q2ae4mE8v6Id3NmMXfNdSnSpP59q8pPyK/GaX6im\n\tljkvG0XgX7+dtoLcc8CRLeKetYKxjUxbkWstQrWqU9fv8yB0OwO5RpWbOvYdSPSNgtIp\n\tDAzw==","X-Gm-Message-State":"ABy/qLYEe7AlbwWCriMjjraX7+SeOvNn7bN8w+fguajXWfLLXvnT5XEb\n\tj/VFrJ+0oj5h6EpWjqxceZYuWyHkcgB4GJ4jMeLbwg==","X-Google-Smtp-Source":"APBJJlEeP4lrMuiO8TWwfSvuFiurKvPbMtAb9Bxv36RuaEzMkHD9QuH5PogPC6LtJfq3A+C8otroQkeU3ogaEtAKq+o=","X-Received":"by 2002:a05:620a:24c2:b0:767:26d:1142 with SMTP id\n\tm2-20020a05620a24c200b00767026d1142mr14498218qkn.21.1688984749354;\n\tMon, 10 Jul 2023 03:25:49 -0700 (PDT)","MIME-Version":"1.0","References":"<20230706013926.218131-1-ben.benson@raspberrypi.com>\n\t<20230706013926.218131-4-ben.benson@raspberrypi.com>","In-Reply-To":"<20230706013926.218131-4-ben.benson@raspberrypi.com>","Date":"Mon, 10 Jul 2023 11:25:38 +0100","Message-ID":"<CAHW6GYLmiJQJPMP_7qDbwef84rePiwmxbD+_HARtBhQGmPHQPw@mail.gmail.com>","To":"Ben Benson <ben.benson@raspberrypi.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH 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":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":27548,"web_url":"https://patchwork.libcamera.org/comment/27548/","msgid":"<CAEmqJPpho30Zm20W3OTfK2CUWyOH7xQZius5TxASV5MYi-o0QQ@mail.gmail.com>","date":"2023-07-12T12:25:10","subject":"Re: [libcamera-devel] [PATCH 3/3] utils: raspberrypi: ctt: Code\n\ttidying","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Ben,\n\nThank you for this patch!\n\nOn Fri, 7 Jul 2023 at 14:41, Ben Benson via libcamera-devel\n<libcamera-devel@lists.libcamera.org> wrote:\n>\n> Altered the way that some lines are laid out, made functions\n> more attractive to look at, and tidied up messy areas.\n>\n> Signed-off-by Ben Benson <ben.benson@raspberrypi.com>\n> ---\n>  utils/raspberrypi/ctt/ctt_ccm.py | 61 +++++++++++++++-----------------\n>  1 file changed, 29 insertions(+), 32 deletions(-)\n>\n> diff --git a/utils/raspberrypi/ctt/ctt_ccm.py b/utils/raspberrypi/ctt/ctt_ccm.py\n> index bd44b4d8..85ca6827 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> +    m_lab = [colors.RGB_to_LAB(color / 256) for color in m_srgb]\n> +    # This produces array of LAB values for ideal color chart)\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> @@ -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,23 @@ 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>          after_gamma_rgb = []\n>          after_gamma_lab = []\n> -        for w in range(24):\n> -            RGB = np.array([r[w], g[w], b[w]])\n> +\n> +        for red, green, blue in zip(r, g, b):\n> +            RGB = np.array([red, green, blue])\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>              optimised_ccm_applied_rgb = np.dot(formatted_optimised_ccm, 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>          '''\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 matricies\n>          '''\n> @@ -303,8 +300,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> +    for red, green, blue in zip(r, g, b):\n> +        RGB = np.array([red, green, blue])\n>          rgb_post_ccm = np.dot(ccm, RGB)  # 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> @@ -315,12 +312,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 +327,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> @@ -341,8 +337,9 @@ calculates the ccm for an individual image.\n>  ccms are calculate in rgb space, and are fit by hand. Although it is a 3x3\n>  matrix, each row must add up to 1 in order to conserve greyness, simplifying\n>  calculation.\n> -Should you want to fit them in another space (e.g. LAB) we wish you the best of\n> -luck and send us the code when you are done! :-)\n> +The initial CCM is calculated in RGB, and then optimised in LAB color space\n> +This simplifies the initial calculation but then gets us the accuracy of\n> +using LAB color space.\n>  \"\"\"\n\nShould this comment move to patch 1/3?\n\nNaush\n\n\n>\n>\n> --\n> 2.34.1\n>","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 B1659BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 12 Jul 2023 12:25:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 25E6F628BF;\n\tWed, 12 Jul 2023 14:25:28 +0200 (CEST)","from mail-yw1-x1133.google.com (mail-yw1-x1133.google.com\n\t[IPv6:2607:f8b0:4864:20::1133])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3DFF9628BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 Jul 2023 14:25:26 +0200 (CEST)","by mail-yw1-x1133.google.com with SMTP id\n\t00721157ae682-5704fce0f23so79393757b3.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 Jul 2023 05:25:26 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1689164728;\n\tbh=DH3v+bRjwKxj6rlbAYY/4NVKwcWKx8FeBcVL8RrRPMA=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=nbBhDhNkC95due8ksz1qpMeeI7TjQmnOgpdNV9sTssyEN8W3bzlG3ShvPgVP4fGFc\n\tTkIIqu79q9u0dn0a0DYsKbMq+iYITsxbVyk8ZQNP43x26chk0OVHLDPsyf78behLIQ\n\tzvXzXTT45B0uwiHqPSQPH69qBYcxz4YKfbB1mtJgA/QkTW7NBB5DevoDVA9Qxl0LXV\n\tAzuzes5irXmgL0h7azCknX7rFw1FBubBLlB0zcqeMOQUbUsWJ7aB7hQ54awhu5A3j9\n\tOiut++nCv5l6PxfT3WvAucFLcjLFt8jscf1b7f7W6XbOScRftbknos2QJ5LkJoLGL2\n\tI1iTNhekdZ51g==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1689164725; x=1691756725;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=Bg5nt+iPXbrsNYdvTv4Knp/4yzQ1JZDSbHpKRWkUOXQ=;\n\tb=NaKU8OLrcgCT3Fb0bdV5v/iI/eDFQPySEQgzc1dB7xUbDx/ulEQHegfzbZefcxQcWv\n\t6WJ2X9Ypnv5eBstrXeJTT8NIJ33EOwa88b8vRVIH5d7Gjzvw2aqB8wiDDZmy0jAwn9pb\n\ttqob8p0RUWrHeNVMee5+sRm/yN8uMQafQNb2V+F4/LAh/KxQcTtSlce6dWKDBKW/taHh\n\tnGxPIWHmPCol9QCBsPJGLeAl9ExnTm05yS4Y4y4pE3JMqb/4Wkj50rWz1k5EIRIGwyeQ\n\ttd9OH9XYDl2vEmf79zSFkGRyY3JFxqQCO2WqcH1Yix4O8+IH+ESisgaqISSVRKMC7b+W\n\tUGXA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"NaKU8OLr\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1689164725; x=1691756725;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=Bg5nt+iPXbrsNYdvTv4Knp/4yzQ1JZDSbHpKRWkUOXQ=;\n\tb=DNrFRNpv4kp9cOBxLshu2JFyGE1DY66uN6VFdeaSiB/roY0cenqtAoy2K+uiD5u/Fk\n\t7StccG/bSkSerMUkghcIh5cnvykNJzb/C/4Jg+UsB/oRfXQ2vX224ZE7igOJfL83n1m2\n\tPG/abn6ErFgnKvht2xqsi2zCexIT8kxYWnsPt/O4DMJGLNvtnGpCh64Dc1W0j+Yd4Dco\n\t3y2Y8PnTbmHb3dmS7ywq4s8irIOOMZ6lWHwOIA67T8yG150RL/qnBHi02DX/tDkuMUIg\n\tG9vDJMZ//Cih00kDEfP77jM2Oqjmbf/wvLskUXQQqjdODLRHnavP+goBEDjzVJSrt5d7\n\tCcpw==","X-Gm-Message-State":"ABy/qLZxaZAdDkfXFXCFIEMvlpHpPnh2eL74G98R6BYcIGLetyY3QJxG\n\tLnEMZE2aIrnNOMQZpwrtfmkKnSDVdzzfUAbefjQMbA0T1V3LkKYDkfU=","X-Google-Smtp-Source":"APBJJlF8ElxdLMsIREOd92AiW5ti+/q8g5UTEN59b1i6RqGte+ioNirHsiCpR5a/Fw1/6HmllnpPM3e7vTjG9Bg5O5U=","X-Received":"by 2002:a0d:dd0f:0:b0:55a:3ce9:dc3d with SMTP id\n\tg15-20020a0ddd0f000000b0055a3ce9dc3dmr18466990ywe.13.1689164725051;\n\tWed, 12 Jul 2023 05:25:25 -0700 (PDT)","MIME-Version":"1.0","References":"<20230706013926.218131-1-ben.benson@raspberrypi.com>\n\t<20230706013926.218131-4-ben.benson@raspberrypi.com>","In-Reply-To":"<20230706013926.218131-4-ben.benson@raspberrypi.com>","Date":"Wed, 12 Jul 2023 13:25:10 +0100","Message-ID":"<CAEmqJPpho30Zm20W3OTfK2CUWyOH7xQZius5TxASV5MYi-o0QQ@mail.gmail.com>","To":"Ben Benson <ben.benson@raspberrypi.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH 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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]