static void transformXYZ2SRGB( const Array2D *inC1, const Array2D *inC2,
const Array2D *inC3, Array2D *outC1, Array2D *outC2, Array2D *outC3 )
{
multiplyByMatrix( outC1, outC2, outC3, outC1, outC2, outC3,
xyz2rgbD65Mat ); <----------------------- This line, for me, is doing
nothing
int imgSize = inC1->getRows()*inC1->getCols();
for( int index = 0; index < imgSize ; index++ ) {
float r = (*inC1)(index), g = (*inC2)(index), b = (*inC3)(index);
float &o_r = (*outC1)(index), &o_g = (*outC2)(index), &o_b =
(*outC3)(index);
r = clamp( r, 0, 1 );
g = clamp( g, 0, 1 );
b = clamp( b, 0, 1 );
o_r = (r <= 0.0031308f ? r *= 12.92f : 1.055f * powf( r, 1./2.4 ) -
0.055f);
o_g = (g <= 0.0031308f ? g *= 12.92f : 1.055f * powf( g, 1./2.4 ) -
0.055f);
o_b = (b <= 0.0031308f ? b *= 12.92f : 1.055f * powf( b, 1./2.4 ) -
0.055f);
}
}
static void multiplyByMatrix( const Array2D *inC1, const Array2D *inC2,
const Array2D *inC3,
Array2D *outC1, Array2D *outC2, Array2D *outC3, const float mat[3][3] )
{
int imgSize = inC1->getRows()*inC1->getCols();
for( int index = 0; index < imgSize ; index++ ) {
const float x1 = (*inC1)(index), x2 = (*inC2)(index), x3 =
(*inC3)(index);
float &y1 = (*outC1)(index), &y2 = (*outC2)(index), &y3 =
(*outC3)(index);
y1 = mat[0][0]*x1 + mat[0][1]*x2 + mat[0][2]*x3;
y2 = mat[1][0]*x1 + mat[1][1]*x2 + mat[1][2]*x3;
y3 = mat[2][0]*x1 + mat[2][1]*x2 + mat[2][2]*x3;
}
}