[{"id":19008,"web_url":"https://patchwork.libcamera.org/comment/19008/","msgid":"<YSPZX9AnEALX3M9C@pendragon.ideasonboard.com>","date":"2021-08-23T17:22:39","subject":"Re: [libcamera-devel] [PATCH v1 4/7] ipa: ipu3: awb: Add some\n\tdocumentation on the algorithm used","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, Aug 23, 2021 at 02:49:34PM +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 | 25 +++++++++++++++++++++++++\n>  1 file changed, 25 insertions(+)\n> \n> diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\n> index 60a5fc52..8e4230b5 100644\n> --- a/src/ipa/ipu3/algorithms/awb.cpp\n> +++ b/src/ipa/ipu3/algorithms/awb.cpp\n> @@ -17,6 +17,31 @@ namespace ipa::ipu3::algorithms {\n>  \n>  LOG_DEFINE_CATEGORY(IPU3Awb)\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\nThe last part of the reference is a bit opaque, should we reference the\nbook (Single-Sensor Imaging: Methods and Applications for Digital\nCameras, pp. 267–294, CRC Press, 2008) ?\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\nParagraph reflow, here and below.\n\n> + *\n> + * The AWB algorithm uses a fixed grid size of kAwbStatsSizeX x kAwbStatsSizeY.\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 IspStatsRegion","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 88F7FBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Aug 2021 17:22:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 14CEB688A3;\n\tMon, 23 Aug 2021 19:22:51 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 927D86025B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Aug 2021 19:22:49 +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 0D76B2A5;\n\tMon, 23 Aug 2021 19:22:48 +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=\"JcDbY8qw\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629739369;\n\tbh=bLyRisBSSjAVRvzu9O2S1+7yrWNogUrQ98Rn4VjQflg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=JcDbY8qwcGJZD7SRTO4h0kO+lHWrGdNMZBdW8SCZBgRCZuMSJu1fIS04WLSs0Ee9f\n\tDd2ysojw/5L4NTIaT4am5MNyPmZVaUKSrF3N1/mNH6xLIpqjXygJ9WhaUIhVo8BvTV\n\tUCDOSz6zhL8djhEX6gBx4THGNuXk1c0ja1tPF3uw=","Date":"Mon, 23 Aug 2021 20:22:39 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<YSPZX9AnEALX3M9C@pendragon.ideasonboard.com>","References":"<20210823124937.253539-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20210823124937.253539-5-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20210823124937.253539-5-jeanmichel.hautbois@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v1 4/7] 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]