[libcamera-devel] [PATCH 06/11] ipa: ipu3: awb: Add AWB class documentation

Laurent Pinchart laurent.pinchart at ideasonboard.com
Tue Sep 14 06:22:38 CEST 2021


Hi Jean-Michel,

Thank you for the patch.

On Mon, Sep 13, 2021 at 04:58:05PM +0200, Jean-Michel Hautbois wrote:
> 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 <jeanmichel.hautbois at ideasonboard.com>
> ---
>  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 <libcamera/base/log.h>
>  
> +/**
> + * \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.

Bad line break.

> + * We then have an average of 2048 R, G and B pixels per cell.

It's exactly 2048 pixels in each cell, not an average.

> + *
> + * The AWB algorithm uses a fixed grid size of kAwbStatsSizeX x kAwbStatsSizeY.

Please tell whether that's a size in pixels, in cells or in something
else.

> + * Each of this new grid cell will be called a zone.

A zone is a group of cells, so I don't think this is right.

> + *
> + * Before calculating the gains, we will convert the statistics from the BDS
> + * grid to an internal grid configuration in generateAwbStats.

"Internal grid" is also not defined. I think moving the diagram from the
Accumulator structure documentation to here, with the associate
documentation, would help. The Accumulator documentation would then only
state that it accumulates red, green and blue values for each
non-saturated items over a zone. I'd also say there that items can for
instance be pixels, but also the average of groups of pixels, depending
on who uses the accumulator.

> + * 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.

Bad line break.

> + * 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.

What happens to the green gain ?

> + */
> +
>  /**
>   * \struct Accumulator
>   * \brief RGB statistics for a given zone

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list