ipa: rkisp1: awb: Prevent RGB means from being negative
Due to hardware rounding errors in the YCbCr means, the calculated RGB means may be negative. This would lead to negative gains, messing up calculation. Prevent this by clamping the means to positive values. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
7d0004a410
commit
c43c8b1fa0
1 changed files with 10 additions and 0 deletions
|
@ -242,6 +242,16 @@ void Awb::process(IPAContext &context,
|
||||||
redMean = 1.1636 * yMean - 0.0623 * cbMean + 1.6008 * crMean;
|
redMean = 1.1636 * yMean - 0.0623 * cbMean + 1.6008 * crMean;
|
||||||
greenMean = 1.1636 * yMean - 0.4045 * cbMean - 0.7949 * crMean;
|
greenMean = 1.1636 * yMean - 0.4045 * cbMean - 0.7949 * crMean;
|
||||||
blueMean = 1.1636 * yMean + 1.9912 * cbMean - 0.0250 * crMean;
|
blueMean = 1.1636 * yMean + 1.9912 * cbMean - 0.0250 * crMean;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Due to hardware rounding errors in the YCbCr means, the
|
||||||
|
* calculated RGB means may be negative. This would lead to
|
||||||
|
* negative gains, messing up calculation. Prevent this by
|
||||||
|
* clamping the means to positive values.
|
||||||
|
*/
|
||||||
|
redMean = std::max(redMean, 0.0);
|
||||||
|
greenMean = std::max(greenMean, 0.0);
|
||||||
|
blueMean = std::max(blueMean, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue