[{"id":19290,"web_url":"https://patchwork.libcamera.org/comment/19290/","msgid":"<61584dbf-581c-5ed9-5789-ab4cdc4d782c@ideasonboard.com>","date":"2021-09-02T12:56:50","subject":"Re: [libcamera-devel] [PATCH] ipa: ipu3: awb: Add some\n\tdocumentation on the algorithm used","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"On 02/09/2021 12:51, Jean-Michel Hautbois wrote:\n> The AWB algorithm is based on the Grey world algorithm and uses the\n> statistics generated by the ImgU for that. Explain how it uses those,\n> and reference the original algorithm at the same time.\n> \n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  src/ipa/ipu3/algorithms/awb.cpp | 26 ++++++++++++++++++++++++++\n>  1 file changed, 26 insertions(+)\n> \n> diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\n> index d97724fa..f0b12d1a 100644\n> --- a/src/ipa/ipu3/algorithms/awb.cpp\n> +++ b/src/ipa/ipu3/algorithms/awb.cpp\n> @@ -20,6 +20,32 @@ LOG_DEFINE_CATEGORY(IPU3Awb)\n>  static constexpr uint32_t kMinZonesCounted = 16;\n>  static constexpr uint32_t kMinGreenLevelInZone = 32;\n>  \n> +/**\n> + * The Grey World algorithm assumes that the scene, in average, is neutral grey.\n> + * Reference: Lam, Edmund & Fung, George. (2008). Automatic White Balancing in\n> + * Digital Photography. 10.1201/9781420054538.ch10.\n\nDoes this mean that /this/ algorithm is an implementation of the Grey\nWorld algorithm?\n\nWe should say so.\n\n\"\"\"\nThis AWB algorithm module provides a simple Grey World algorithm\nimplementation based upon the procedures and methods described in\nAutomatic White Balancing in Digital Photography.\n\nThe Grey World algorithm assumes that the scene, in average, is a\nneutral grey.\n\nReference: Lam, Edmund & Fung, George. (2008). Automatic White Balancing\nin Digital Photography. 10.1201/9781420054538.ch10.\n\"\"\"\n\n> + *\n> + * The IPU3 generates statistics from the Bayer Down Scaler output into a grid\n> + * defined in the ipu3_uapi_awb_config_s structure.\n> + *\n> + * For example, when the BDS outputs a frame of 2592x1944, the grid may be\n> + * configured to 81x30 cells each with a size of 32x64 pixels.\n> + * We then have an average of 2048 R, G and B pixels per cell.\n> + *\n> + * The AWB algorithm uses a fixed grid size of kAwbStatsSizeX x kAwbStatsSizeY.\n\n\"This AWB algorithm\" ?\n\nBut otherwise,\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> + * Each of this new grid cell will be called a zone.\n> + *\n> + * Before calculating the gains, we will convert the statistics from the BDS\n> + * grid to an internal grid configuration in generateAwbStats.\n> + * As part of converting the statistics to an internal grid, the saturation\n> + * flag from the originating grid cell is used to decide if the zone contains\n> + * saturated pixels or not, making the zone relevant or not.\n> + * A saturated zone will be excluded from the calculation.\n> + *\n> + * The Grey World algorithm will then estimate the red and blue gains to apply, and\n> + * store the results in the metadata.\n> + */\n> +\n>  /**\n>   * \\struct Accumulator\n>   * \\brief RGB statistics for a given region\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 16AF6BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Sep 2021 12:56:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8283C69166;\n\tThu,  2 Sep 2021 14:56:56 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4DB7360255\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 Sep 2021 14:56:54 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D5369317;\n\tThu,  2 Sep 2021 14:56:53 +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=\"n8NdsTMy\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630587414;\n\tbh=SRpjtfRzjJYpqjjCbVnr89MGsl9VUHZKYxL5zbI9sBA=;\n\th=To:References:From:Subject:Date:In-Reply-To:From;\n\tb=n8NdsTMydECVyw1BMbzZylk7UKyfiy2DCG86zWXhw2IlBsUv7YEIhglFkA/stTUpQ\n\tJnTkj8uZ4Twx2syocVN+gtMoB52Q3iY8MluH9cYv7VJ8VFTY6dZ1pxssqu0RZISAjL\n\txdVljb4fg2etIthD4pbIOjnZCStxcTZE3utekr6I=","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210902115135.62199-1-jeanmichel.hautbois@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<61584dbf-581c-5ed9-5789-ab4cdc4d782c@ideasonboard.com>","Date":"Thu, 2 Sep 2021 13:56:50 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.11.0","MIME-Version":"1.0","In-Reply-To":"<20210902115135.62199-1-jeanmichel.hautbois@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH] ipa: ipu3: awb: Add some\n\tdocumentation on the algorithm used","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>"}}]