[{"id":19659,"web_url":"https://patchwork.libcamera.org/comment/19659/","msgid":"<YUAjjtPyi7Gcoerl@pendragon.ideasonboard.com>","date":"2021-09-14T04:22:38","subject":"Re: [libcamera-devel] [PATCH 06/11] ipa: ipu3: awb: Add AWB class\n\tdocumentation","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jean-Michel,\n\nThank you for the patch.\n\nOn Mon, Sep 13, 2021 at 04:58:05PM +0200, 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 | 33 +++++++++++++++++++++++++++++++++\n>  1 file changed, 33 insertions(+)\n> \n> diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\n> index 36e80306..887ac4b5 100644\n> --- a/src/ipa/ipu3/algorithms/awb.cpp\n> +++ b/src/ipa/ipu3/algorithms/awb.cpp\n> @@ -11,6 +11,10 @@\n>  \n>  #include <libcamera/base/log.h>\n>  \n> +/**\n> + * \\file awb.h\n> + */\n> +\n>  namespace libcamera {\n>  \n>  namespace ipa::ipu3::algorithms {\n> @@ -20,6 +24,35 @@ LOG_DEFINE_CATEGORY(IPU3Awb)\n>  static constexpr uint32_t kMinZonesCounted = 16;\n>  static constexpr uint32_t kMinGreenLevelInZone = 32;\n>  \n> +/**\n> + * \\class Awb\n> + * \\brief A Grey world white balance correction algorithm\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> + *\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\nBad line break.\n\n> + * We then have an average of 2048 R, G and B pixels per cell.\n\nIt's exactly 2048 pixels in each cell, not an average.\n\n> + *\n> + * The AWB algorithm uses a fixed grid size of kAwbStatsSizeX x kAwbStatsSizeY.\n\nPlease tell whether that's a size in pixels, in cells or in something\nelse.\n\n> + * Each of this new grid cell will be called a zone.\n\nA zone is a group of cells, so I don't think this is right.\n\n> + *\n> + * Before calculating the gains, we will convert the statistics from the BDS\n> + * grid to an internal grid configuration in generateAwbStats.\n\n\"Internal grid\" is also not defined. I think moving the diagram from the\nAccumulator structure documentation to here, with the associate\ndocumentation, would help. The Accumulator documentation would then only\nstate that it accumulates red, green and blue values for each\nnon-saturated items over a zone. I'd also say there that items can for\ninstance be pixels, but also the average of groups of pixels, depending\non who uses the accumulator.\n\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\nBad line break.\n\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\nWhat happens to the green gain ?\n\n> + */\n> +\n>  /**\n>   * \\struct Accumulator\n>   * \\brief RGB statistics for a given zone","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 F1F84BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 14 Sep 2021 04:23:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 51F8A69187;\n\tTue, 14 Sep 2021 06:23:04 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E57456916F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 14 Sep 2021 06:23:02 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 614AA2A5;\n\tTue, 14 Sep 2021 06:23:02 +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=\"Jwax/4rf\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631593382;\n\tbh=EH15/nSZ+P3noHkVuPdn0im271lr5DRxW+BoesECf8g=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Jwax/4rfhQS8aKQJwHR6wg9WtJ8fcCQzNYAL8n4Vj9zI0rkz0wZe0XlFql4vbjj+/\n\tzdqVPrX5iBXMVWVq+s2wuYwSR6KSp2j68IOt65s+tVPjvMv2eZVGz7wDfMHGcas4r4\n\t15A0vYFbvcn+wHlV75dwRhefeddrr4LLxl6GQmbA=","Date":"Tue, 14 Sep 2021 07:22:38 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<YUAjjtPyi7Gcoerl@pendragon.ideasonboard.com>","References":"<20210913145810.66515-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20210913145810.66515-7-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210913145810.66515-7-jeanmichel.hautbois@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 06/11] ipa: ipu3: awb: Add AWB class\n\tdocumentation","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]