ipa: rkisp1: awb: Use Vector and Matrix for linear algebra
Replace the manual vector and matrix calculations with usage of the Vector and Matrix classes. This simplifies the code and improves readability. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
This commit is contained in:
parent
01919308e9
commit
be22d4aa77
1 changed files with 15 additions and 11 deletions
|
@ -203,9 +203,11 @@ void Awb::process(IPAContext &context,
|
||||||
}};
|
}};
|
||||||
} else {
|
} else {
|
||||||
/* Get the YCbCr mean values */
|
/* Get the YCbCr mean values */
|
||||||
double yMean = awb->awb_mean[0].mean_y_or_g;
|
Vector<double, 3> yuvMeans({
|
||||||
double cbMean = awb->awb_mean[0].mean_cb_or_b;
|
static_cast<double>(awb->awb_mean[0].mean_y_or_g),
|
||||||
double crMean = awb->awb_mean[0].mean_cr_or_r;
|
static_cast<double>(awb->awb_mean[0].mean_cb_or_b),
|
||||||
|
static_cast<double>(awb->awb_mean[0].mean_cr_or_r)
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert from YCbCr to RGB.
|
* Convert from YCbCr to RGB.
|
||||||
|
@ -219,14 +221,16 @@ void Awb::process(IPAContext &context,
|
||||||
* [1,1636, -0,4045, -0,7949]
|
* [1,1636, -0,4045, -0,7949]
|
||||||
* [1,1636, 1,9912, -0,0250]]
|
* [1,1636, 1,9912, -0,0250]]
|
||||||
*/
|
*/
|
||||||
yMean -= 16;
|
static const Matrix<double, 3, 3> yuv2rgbMatrix({
|
||||||
cbMean -= 128;
|
1.1636, -0.0623, 1.6008,
|
||||||
crMean -= 128;
|
1.1636, -0.4045, -0.7949,
|
||||||
rgbMeans = {{
|
1.1636, 1.9912, -0.0250
|
||||||
1.1636 * yMean - 0.0623 * cbMean + 1.6008 * crMean,
|
});
|
||||||
1.1636 * yMean - 0.4045 * cbMean - 0.7949 * crMean,
|
static const Vector<double, 3> yuv2rgbOffset({
|
||||||
1.1636 * yMean + 1.9912 * cbMean - 0.0250 * crMean
|
16, 128, 128
|
||||||
}};
|
});
|
||||||
|
|
||||||
|
rgbMeans = yuv2rgbMatrix * (yuvMeans - yuv2rgbOffset);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Due to hardware rounding errors in the YCbCr means, the
|
* Due to hardware rounding errors in the YCbCr means, the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue