[v2,13/17] ipa: rkisp1: awb: Use gains from color temperature curve
diff mbox series

Message ID 20250319161152.63625-14-stefan.klug@ideasonboard.com
State Superseded
Headers show
Series
  • Some rkisp1 awb improvements
Related show

Commit Message

Stefan Klug March 19, 2025, 4:11 p.m. UTC
Use the color gains for white balance if calibrated light sources are
contained in the tuning file. The results are generally better
especially when large uniformly colored objects are in the scene. Pure
grey world model is still available by removing the color gains from the
tuning file.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---
 src/ipa/rkisp1/algorithms/awb.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Kieran Bingham March 31, 2025, 5:46 p.m. UTC | #1
Quoting Stefan Klug (2025-03-19 16:11:18)
> Use the color gains for white balance if calibrated light sources are
> contained in the tuning file. The results are generally better
> especially when large uniformly colored objects are in the scene. Pure
> grey world model is still available by removing the color gains from the
> tuning file.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> ---
>  src/ipa/rkisp1/algorithms/awb.cpp | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
> index 58b8370d2c61..286d9e3e2018 100644
> --- a/src/ipa/rkisp1/algorithms/awb.cpp
> +++ b/src/ipa/rkisp1/algorithms/awb.cpp
> @@ -218,6 +218,16 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,
>                 auto &awb = context.activeState.awb;
>                 frameContext.awb.gains = awb.automatic.gains;
>                 frameContext.awb.temperatureK = awb.automatic.temperatureK;
> +
> +               const auto &gains = awbAlgo_->gainsFromColourTemperature(
> +                       awb.automatic.temperatureK);
> +               if (gains) {
> +                       frameContext.awb.gains.r() = gains->r();
> +                       frameContext.awb.gains.g() = 1.0;
> +                       frameContext.awb.gains.b() = gains->b();
> +               } else {
> +                       frameContext.awb.gains = awb.automatic.gains;
> +               }
>         }
>  
>         auto gainConfig = params->block<BlockType::AwbGain>();
> -- 
> 2.43.0
>
Laurent Pinchart April 1, 2025, 2:02 a.m. UTC | #2
Hi Stefan,

Thank you for the patch.

On Wed, Mar 19, 2025 at 05:11:18PM +0100, Stefan Klug wrote:
> Use the color gains for white balance if calibrated light sources are
> contained in the tuning file. The results are generally better
> especially when large uniformly colored objects are in the scene. Pure
> grey world model is still available by removing the color gains from the
> tuning file.

We'll get an error in the log for every frame then. I think that needs
to be addressed.

> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> ---
>  src/ipa/rkisp1/algorithms/awb.cpp | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
> index 58b8370d2c61..286d9e3e2018 100644
> --- a/src/ipa/rkisp1/algorithms/awb.cpp
> +++ b/src/ipa/rkisp1/algorithms/awb.cpp
> @@ -218,6 +218,16 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,
>  		auto &awb = context.activeState.awb;
>  		frameContext.awb.gains = awb.automatic.gains;

This doesn't seem to be needed anymore.

>  		frameContext.awb.temperatureK = awb.automatic.temperatureK;
> +
> +		const auto &gains = awbAlgo_->gainsFromColourTemperature(
> +			awb.automatic.temperatureK);
> +		if (gains) {
> +			frameContext.awb.gains.r() = gains->r();
> +			frameContext.awb.gains.g() = 1.0;
> +			frameContext.awb.gains.b() = gains->b();
> +		} else {
> +			frameContext.awb.gains = awb.automatic.gains;
> +		}

Shouldn't this be done in Awb::process() where awb.automatic.gains is
set ? Or maybe even in calculateAwb() ?

>  	}
>  
>  	auto gainConfig = params->block<BlockType::AwbGain>();

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
index 58b8370d2c61..286d9e3e2018 100644
--- a/src/ipa/rkisp1/algorithms/awb.cpp
+++ b/src/ipa/rkisp1/algorithms/awb.cpp
@@ -218,6 +218,16 @@  void Awb::prepare(IPAContext &context, const uint32_t frame,
 		auto &awb = context.activeState.awb;
 		frameContext.awb.gains = awb.automatic.gains;
 		frameContext.awb.temperatureK = awb.automatic.temperatureK;
+
+		const auto &gains = awbAlgo_->gainsFromColourTemperature(
+			awb.automatic.temperatureK);
+		if (gains) {
+			frameContext.awb.gains.r() = gains->r();
+			frameContext.awb.gains.g() = 1.0;
+			frameContext.awb.gains.b() = gains->b();
+		} else {
+			frameContext.awb.gains = awb.automatic.gains;
+		}
 	}
 
 	auto gainConfig = params->block<BlockType::AwbGain>();