[libcamera-devel] [PATCH v1 2/7] ipa: ipu3: awb: Correct the relevant zones proportion
Jean-Michel Hautbois
jeanmichel.hautbois at ideasonboard.com
Mon Aug 23 14:49:32 CEST 2021
The algorithm uses the statistics of a cell only if there is not too
much saturated pixels in it. The grey world algorithm works fine when
there are a limited number of outliers.
Consider a valid zone to be at least 80% of unsaturated cells in it.
This value could very well be configurable, and make the algorithm more
or less tolerant.
Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois at ideasonboard.com>
---
src/ipa/ipu3/algorithms/awb.cpp | 15 ++++++++++++---
src/ipa/ipu3/algorithms/awb.h | 1 +
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp
index e05647c9..9497a21b 100644
--- a/src/ipa/ipu3/algorithms/awb.cpp
+++ b/src/ipa/ipu3/algorithms/awb.cpp
@@ -17,8 +17,6 @@ namespace ipa::ipu3::algorithms {
LOG_DEFINE_CATEGORY(IPU3Awb)
-static constexpr uint32_t kMinZonesCounted = 16;
-static constexpr uint32_t kMinGreenLevelInZone = 32;
/**
* \struct IspStatsRegion
@@ -114,6 +112,9 @@ static const struct ipu3_uapi_ccm_mat_config imguCssCcmDefault = {
0, 0, 8191, 0
};
+/* Minimum level of green in a given zone */
+static constexpr uint32_t kMinGreenLevelInZone = 16;
+
Awb::Awb()
: Algorithm()
{
@@ -123,6 +124,7 @@ Awb::Awb()
asyncResults_.temperatureK = 4500;
zones_.reserve(kAwbStatsSizeX * kAwbStatsSizeY);
+ minZonesCounted_ = 0;
}
Awb::~Awb() = default;
@@ -163,7 +165,7 @@ void Awb::generateZones(std::vector<RGB> &zones)
for (unsigned int i = 0; i < kAwbStatsSizeX * kAwbStatsSizeY; i++) {
RGB zone;
double counted = awbStats_[i].counted;
- if (counted >= kMinZonesCounted) {
+ if (counted >= minZonesCounted_) {
zone.G = awbStats_[i].gSum / counted;
if (zone.G >= kMinGreenLevelInZone) {
zone.R = awbStats_[i].rSum / counted;
@@ -181,6 +183,13 @@ void Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats,
uint32_t regionWidth = round(grid.width / static_cast<double>(kAwbStatsSizeX));
uint32_t regionHeight = round(grid.height / static_cast<double>(kAwbStatsSizeY));
+ /*
+ * It is the minimum proportion of pixels counted within AWB region
+ * for it to be relevant.
+ * \todo This proportion could be configured.
+ */
+ minZonesCounted_ = (regionWidth * regionHeight) * 80 / 100;
+
/*
* Generate a (kAwbStatsSizeX x kAwbStatsSizeY) array from the IPU3 grid which is
* (grid.width x grid.height).
diff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h
index 332652d0..95238b6a 100644
--- a/src/ipa/ipu3/algorithms/awb.h
+++ b/src/ipa/ipu3/algorithms/awb.h
@@ -84,6 +84,7 @@ private:
std::vector<RGB> zones_;
IspStatsRegion awbStats_[kAwbStatsSizeX * kAwbStatsSizeY];
AwbStatus asyncResults_;
+ uint32_t minZonesCounted_;
};
} /* namespace ipa::ipu3::algorithms */
--
2.30.2
More information about the libcamera-devel
mailing list