[{"id":19003,"web_url":"https://patchwork.libcamera.org/comment/19003/","msgid":"<YSPHOIhVKEnQCcqn@pendragon.ideasonboard.com>","date":"2021-08-23T16:05:12","subject":"Re: [libcamera-devel] [PATCH v1 2/7] ipa: ipu3: awb: Correct the\n\trelevant zones proportion","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:32PM +0200, Jean-Michel Hautbois wrote:\n> The algorithm uses the statistics of a cell only if there is not too\n> much saturated pixels in it. The grey world algorithm works fine when\n\ns/much/many/\n\n> there are a limited number of outliers.\n\nBlank line or no line break, your decision.\n\n> Consider a valid zone to be at least 80% of unsaturated cells in it.\n> This value could very well be configurable, and make the algorithm more\n> or less tolerant.\n\nYou use \"zone\", \"cell\" and \"pixel\" in a way that confuses me (but it may\nbe me). In the first paragraph a cell is made of pixels, and in the\nsecond paragraph a zone is made of cells. Furthermore, we have a\nIspStatsRegion structure that mentions \"region\".\n\nIt would be easier to review this if there were a patch earlier in the\nseries that cleaned up the vocabulary.\n\n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  src/ipa/ipu3/algorithms/awb.cpp | 15 ++++++++++++---\n>  src/ipa/ipu3/algorithms/awb.h   |  1 +\n>  2 files changed, 13 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\n> index e05647c9..9497a21b 100644\n> --- a/src/ipa/ipu3/algorithms/awb.cpp\n> +++ b/src/ipa/ipu3/algorithms/awb.cpp\n> @@ -17,8 +17,6 @@ namespace ipa::ipu3::algorithms {\n>  \n>  LOG_DEFINE_CATEGORY(IPU3Awb)\n>  \n> -static constexpr uint32_t kMinZonesCounted = 16;\n> -static constexpr uint32_t kMinGreenLevelInZone = 32;\n>  \n>  /**\n>   * \\struct IspStatsRegion\n> @@ -114,6 +112,9 @@ static const struct ipu3_uapi_ccm_mat_config imguCssCcmDefault = {\n>  \t0, 0, 8191, 0\n>  };\n>  \n> +/* Minimum level of green in a given zone */\n> +static constexpr uint32_t kMinGreenLevelInZone = 16;\n> +\n>  Awb::Awb()\n>  \t: Algorithm()\n>  {\n> @@ -123,6 +124,7 @@ Awb::Awb()\n>  \tasyncResults_.temperatureK = 4500;\n>  \n>  \tzones_.reserve(kAwbStatsSizeX * kAwbStatsSizeY);\n> +\tminZonesCounted_ = 0;\n>  }\n>  \n>  Awb::~Awb() = default;\n> @@ -163,7 +165,7 @@ void Awb::generateZones(std::vector<RGB> &zones)\n>  \tfor (unsigned int i = 0; i < kAwbStatsSizeX * kAwbStatsSizeY; i++) {\n>  \t\tRGB zone;\n>  \t\tdouble counted = awbStats_[i].counted;\n> -\t\tif (counted >= kMinZonesCounted) {\n> +\t\tif (counted >= minZonesCounted_) {\n>  \t\t\tzone.G = awbStats_[i].gSum / counted;\n>  \t\t\tif (zone.G >= kMinGreenLevelInZone) {\n>  \t\t\t\tzone.R = awbStats_[i].rSum / counted;\n> @@ -181,6 +183,13 @@ void Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats,\n>  \tuint32_t regionWidth = round(grid.width / static_cast<double>(kAwbStatsSizeX));\n>  \tuint32_t regionHeight = round(grid.height / static_cast<double>(kAwbStatsSizeY));\n>  \n> +\t/*\n> +\t * It is the minimum proportion of pixels counted within AWB region\n> +\t * for it to be relevant.\n> +\t * \\todo This proportion could be configured.\n> +\t */\n> +\tminZonesCounted_ = (regionWidth * regionHeight) * 80 / 100;\n\nThe grid is a configuration parameter that doesn't change during the\ncapture session, right ? This should then be moved to configure().\n\n> +\n>  \t/*\n>  \t * Generate a (kAwbStatsSizeX x kAwbStatsSizeY) array from the IPU3 grid which is\n>  \t * (grid.width x grid.height).\n> diff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h\n> index 332652d0..95238b6a 100644\n> --- a/src/ipa/ipu3/algorithms/awb.h\n> +++ b/src/ipa/ipu3/algorithms/awb.h\n> @@ -84,6 +84,7 @@ private:\n>  \tstd::vector<RGB> zones_;\n>  \tIspStatsRegion awbStats_[kAwbStatsSizeX * kAwbStatsSizeY];\n>  \tAwbStatus asyncResults_;\n> +\tuint32_t minZonesCounted_;\n>  };\n>  \n>  } /* namespace ipa::ipu3::algorithms */","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 882D2BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Aug 2021 16:05:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E6FBF688A3;\n\tMon, 23 Aug 2021 18:05:23 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5DD976025B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Aug 2021 18:05:22 +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 D956F2A5;\n\tMon, 23 Aug 2021 18:05:21 +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=\"MnaID3Z0\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629734722;\n\tbh=8HaV5HzzdUstst/l7XlcXSRolQVvC8oFqJvXHRWOOTE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=MnaID3Z0Tjg3y6K6L7bRixqx/xCQgEitmLKoGOgaRrSckdVEwBbiz1Z6s8DUk14Mr\n\tEW9EIveNpdHctOIqej87YcmIxXyWZH/dGUI+zwiE3l6vlLyjo1Czv4atd7orR7Czac\n\tkCZmTgfq10c4/E6+yxG4jj78zs+JKX7lWGju/oyM=","Date":"Mon, 23 Aug 2021 19:05:12 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<YSPHOIhVKEnQCcqn@pendragon.ideasonboard.com>","References":"<20210823124937.253539-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20210823124937.253539-3-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210823124937.253539-3-jeanmichel.hautbois@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v1 2/7] ipa: ipu3: awb: Correct the\n\trelevant zones proportion","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>"}}]