[{"id":30128,"web_url":"https://patchwork.libcamera.org/comment/30128/","msgid":"<20240628222655.GB30900@pendragon.ideasonboard.com>","date":"2024-06-28T22:26:55","subject":"Re: [PATCH v2 04/25] libtuning: Copy visualize_macbeth_chart from\n\traspberry pi","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Stefan,\n\nOn Fri, Jun 28, 2024 at 12:46:57PM +0200, Stefan Klug wrote:\n> Copy visualize_macbeth_chart from raspberry pi.  It is copied verbatim\n> and does not work in this state.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  utils/tuning/libtuning/utils.py | 43 +++++++++++++++++++++++++++++++++\n>  1 file changed, 43 insertions(+)\n> \n> diff --git a/utils/tuning/libtuning/utils.py b/utils/tuning/libtuning/utils.py\n> index 1e8128ea0571..f099c0ed685c 100644\n> --- a/utils/tuning/libtuning/utils.py\n> +++ b/utils/tuning/libtuning/utils.py\n> @@ -123,3 +123,46 @@ def load_images(input_dir: str, config: dict, load_nonlsc: bool, load_lsc: bool)\n>          return None\n>  \n>      return images\n> +\n> +\n> +\n> +\"\"\"\n> +Some code that will save virtual macbeth charts that show the difference between optimised matrices and non optimised matrices\n> +\n> +The function creates an image that is 1550 by 1050 pixels wide, and fills it with patches which are 200x200 pixels in size\n> +Each patch contains the ideal color, the color from the original matrix, and the color from the final matrix\n> +_________________\n> +|               |\n> +|  Ideal Color  |\n> +|_______________|\n> +|  Old  |  new  |\n> +| Color | Color |\n> +|_______|_______|\n> +\n> +Nice way of showing how the optimisation helps change the colors and the color matricies\n> +\"\"\"\n> +def visualise_macbeth_chart(macbeth_rgb, original_rgb, new_rgb, output_filename):\n> +    image = np.zeros((1050, 1550, 3), dtype=np.uint8)\n> +    colorindex = -1\n> +    for y in range(6):\n> +        for x in range(4):  # Creates 6 x 4 grid of macbeth chart\n> +            colorindex += 1\n> +            xlocation = 50 + 250 * x  # Means there is 50px of black gap between each square, more like the real macbeth chart.\n> +            ylocation = 50 + 250 * y\n> +            for g in range(200):\n> +                for i in range(100):\n> +                    image[xlocation + i, ylocation + g] = macbeth_rgb[colorindex]\n> +            xlocation = 150 + 250 * x\n> +            ylocation = 50 + 250 * y\n> +            for i in range(100):\n> +                for g in range(100):\n> +                    image[xlocation + i, ylocation + g] = original_rgb[colorindex]  # Smaller squares below to compare the old colors with the new ones\n> +            xlocation = 150 + 250 * x\n> +            ylocation = 150 + 250 * y\n> +            for i in range(100):\n> +                for g in range(100):\n> +                    image[xlocation + i, ylocation + g] = new_rgb[colorindex]\n> +\n> +    img = Image.fromarray(image, 'RGB')\n> +    img.save(str(output_filename) + 'Generated Macbeth Chart.png')\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 A09D5BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 28 Jun 2024 22:27:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DF7D062C99;\n\tSat, 29 Jun 2024 00:27:18 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D8AC1619E8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Jun 2024 00:27:16 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AA911471;\n\tSat, 29 Jun 2024 00:26:51 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"U+i/x1OK\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719613611;\n\tbh=U2n7yWfNz/Bx5qzUbhbCZFL4Z6oD+emmNwmac772DoU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=U+i/x1OKT1l3DFRRZnY18ikZOIcr9QXJouV4cOOnZxIOIZY+4M8Hzh/D880DJTlIS\n\tQ9heQtuB4IXcU4gdbxfR9lbPYrSS6KEMcpVMdKdSnqtDu23wVU6c+Iyl0Mj5B4Kine\n\t3sD591w2Y7UPNzkb7fJKh4ceKafVM4vTXL9VJU8I=","Date":"Sat, 29 Jun 2024 01:26:55 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 04/25] libtuning: Copy visualize_macbeth_chart from\n\traspberry pi","Message-ID":"<20240628222655.GB30900@pendragon.ideasonboard.com>","References":"<20240628104828.2928109-1-stefan.klug@ideasonboard.com>\n\t<20240628104828.2928109-5-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240628104828.2928109-5-stefan.klug@ideasonboard.com>","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>"}}]