From patchwork Mon Sep 13 14:58:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 13834 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id D0D49BDB1D for ; Mon, 13 Sep 2021 14:58:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 75D8D6919B; Mon, 13 Sep 2021 16:58:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WdQYhaCj"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3D6D269181 for ; Mon, 13 Sep 2021 16:58:15 +0200 (CEST) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:edc5:688b:2ede:8b4b]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E2554510; Mon, 13 Sep 2021 16:58:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1631545095; bh=u/R0B1lt/cG9gs3pLw+ld3FyrrYHLqI6ag/XioyEL/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WdQYhaCjBItiSRWBv51f0LQpJ2ZBYARXiPZRDr5CnAwDhVW/qUJPd5xDw50psICUx JaZKbua+tUKEpKQk9Udr+fh+b/GKnSiM3LMol/Zro8eQIQ3lsiotzk2VbBQVUBKP16 ovGzyMCbEoaHdYwrafF7JN4HVwvsCJSimcxezSUU= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Mon, 13 Sep 2021 16:58:05 +0200 Message-Id: <20210913145810.66515-7-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210913145810.66515-1-jeanmichel.hautbois@ideasonboard.com> References: <20210913145810.66515-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 06/11] ipa: ipu3: awb: Add AWB class documentation X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The AWB algorithm is based on the Grey world algorithm and uses the statistics generated by the ImgU for that. Explain how it uses those, and reference the original algorithm at the same time. Signed-off-by: Jean-Michel Hautbois --- src/ipa/ipu3/algorithms/awb.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp index 36e80306..887ac4b5 100644 --- a/src/ipa/ipu3/algorithms/awb.cpp +++ b/src/ipa/ipu3/algorithms/awb.cpp @@ -11,6 +11,10 @@ #include +/** + * \file awb.h + */ + namespace libcamera { namespace ipa::ipu3::algorithms { @@ -20,6 +24,35 @@ LOG_DEFINE_CATEGORY(IPU3Awb) static constexpr uint32_t kMinZonesCounted = 16; static constexpr uint32_t kMinGreenLevelInZone = 32; +/** + * \class Awb + * \brief A Grey world white balance correction algorithm + * + * The Grey World algorithm assumes that the scene, in average, is neutral grey. + * Reference: Lam, Edmund & Fung, George. (2008). Automatic White Balancing in + * Digital Photography. 10.1201/9781420054538.ch10. + * + * The IPU3 generates statistics from the Bayer Down Scaler output into a grid + * defined in the ipu3_uapi_awb_config_s structure. + * + * For example, when the BDS outputs a frame of 2592x1944, the grid may be + * configured to 81x30 cells each with a size of 32x64 pixels. + * We then have an average of 2048 R, G and B pixels per cell. + * + * The AWB algorithm uses a fixed grid size of kAwbStatsSizeX x kAwbStatsSizeY. + * Each of this new grid cell will be called a zone. + * + * Before calculating the gains, we will convert the statistics from the BDS + * grid to an internal grid configuration in generateAwbStats. + * As part of converting the statistics to an internal grid, the saturation + * flag from the originating grid cell is used to decide if the zone contains + * saturated pixels or not, making the zone relevant or not. + * A saturated zone will be excluded from the calculation. + * + * The Grey World algorithm will then estimate the red and blue gains to apply, and + * store the results in the metadata. + */ + /** * \struct Accumulator * \brief RGB statistics for a given zone