[{"id":30295,"web_url":"https://patchwork.libcamera.org/comment/30295/","msgid":"<ZoZkggEa07QXLYDu@pyrite.rasen.tech>","date":"2024-07-04T08:59:46","subject":"Re: [PATCH v3 04/23] libtuning: Copy visualize_macbeth_chart from\n\traspberry pi","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Wed, Jul 03, 2024 at 04:16:53PM +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> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nAcked-by: Paul Elder <paul.elder@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> +\n> -- \n> 2.43.0\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 DDA28BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Jul 2024 08:59:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9EC0B62E22;\n\tThu,  4 Jul 2024 10:59:55 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 338F1619C4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Jul 2024 10:59:54 +0200 (CEST)","from pyrite.rasen.tech (h175-177-049-156.catv02.itscom.jp\n\t[175.177.49.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CCDF283F;\n\tThu,  4 Jul 2024 10:59:23 +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=\"sjEUhWRb\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1720083565;\n\tbh=xht5DwrW1yHSO/uoW8LrfhHW7SsWIGZuX5jlabvKUOM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=sjEUhWRbWL7nrdiSqfp1L6NmIExT583lLOi8+cdQ22/f2KCxoOl1StisQ/7G+mWNO\n\tQHmRlDtFz0rPS0HXPk8s7L1rSZrj7TPKyE3nVeYUqgOrg9R0TYmJAI9pgK0NnJf/AX\n\tUHlwQHknoqlZoshn/6szJkA8aDM3mDquylJWHyK0=","Date":"Thu, 4 Jul 2024 17:59:46 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH v3 04/23] libtuning: Copy visualize_macbeth_chart from\n\traspberry pi","Message-ID":"<ZoZkggEa07QXLYDu@pyrite.rasen.tech>","References":"<20240703141726.252368-1-stefan.klug@ideasonboard.com>\n\t<20240703141726.252368-5-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20240703141726.252368-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>"}}]