[libcamera-devel,v2,04/13] ipa: ipu3: awb: Change minimal green threshold value
diff mbox series

Message ID 20211020154607.180161-5-jeanmichel.hautbois@ideasonboard.com
State Superseded
Headers show
Series
  • ipa: ipu3: Fix AGC bugs
Related show

Commit Message

Jean-Michel Hautbois Oct. 20, 2021, 3:45 p.m. UTC
When zones are used for the grey world algorithm, they are only
considered if their average green value is at least 32/255 to exclude
zones that are too dark and don't provide relevant colour information
(on the opposite side of the spectrum, saturated regions are excluded by
the ImgU statistics engine).

The algorithm requires a minimal number of zones that meet this criteria
in order to run. Now that we correct the black level, the 32/255 minimal
value is a bit high and prevents the algorithm for running in low-light
conditions. Lower the value to 16/255 to fix it.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/ipa/ipu3/algorithms/awb.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Oct. 21, 2021, 2:12 a.m. UTC | #1
Hi Jean-Michel,

Thank you for the patch.

On Wed, Oct 20, 2021 at 05:45:58PM +0200, Jean-Michel Hautbois wrote:
> When zones are used for the grey world algorithm, they are only
> considered if their average green value is at least 32/255 to exclude
> zones that are too dark and don't provide relevant colour information
> (on the opposite side of the spectrum, saturated regions are excluded by
> the ImgU statistics engine).
> 
> The algorithm requires a minimal number of zones that meet this criteria
> in order to run. Now that we correct the black level, the 32/255 minimal
> value is a bit high and prevents the algorithm for running in low-light
> conditions. Lower the value to 16/255 to fix it.
> 
> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/ipa/ipu3/algorithms/awb.cpp | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp
> index 62c72cce..1ffb431b 100644
> --- a/src/ipa/ipu3/algorithms/awb.cpp
> +++ b/src/ipa/ipu3/algorithms/awb.cpp
> @@ -17,7 +17,13 @@ namespace ipa::ipu3::algorithms {
>  
>  LOG_DEFINE_CATEGORY(IPU3Awb)
>  
> -static constexpr uint32_t kMinGreenLevelInZone = 32;
> +/*
> + * When zones are used for the grey world algorithm, they are only considered if
> + * their average green value is at least 16/255 to exclude zones that are too

 * their average green value is at least 16/255 (after black level subtraction)
 * to exclude zones that are too ...

> + * dark and don't provide relevant colour information (on the opposite side of
> + * the spectrum, saturated regions are excluded by the ImgU statistics engine).
> + */
> +static constexpr uint32_t kMinGreenLevelInZone = 16;
>  
>  /* Minimum proportion of cells counted within a zone for it to be relevant */
>  static constexpr double kMinRelevantCellsRatio = 0.8;

Patch
diff mbox series

diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp
index 62c72cce..1ffb431b 100644
--- a/src/ipa/ipu3/algorithms/awb.cpp
+++ b/src/ipa/ipu3/algorithms/awb.cpp
@@ -17,7 +17,13 @@  namespace ipa::ipu3::algorithms {
 
 LOG_DEFINE_CATEGORY(IPU3Awb)
 
-static constexpr uint32_t kMinGreenLevelInZone = 32;
+/*
+ * When zones are used for the grey world algorithm, they are only considered if
+ * their average green value is at least 16/255 to exclude zones that are too
+ * dark and don't provide relevant colour information (on the opposite side of
+ * the spectrum, saturated regions are excluded by the ImgU statistics engine).
+ */
+static constexpr uint32_t kMinGreenLevelInZone = 16;
 
 /* Minimum proportion of cells counted within a zone for it to be relevant */
 static constexpr double kMinRelevantCellsRatio = 0.8;