Dummy Code ?

13 views
Skip to first unread message

Luis Carlos Carneiro Gonçalves

unread,
Apr 4, 2017, 4:58:25 PM4/4/17
to pfstools
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;
  }

Rafal

unread,
Apr 4, 2017, 5:03:09 PM4/4/17
to pfstools


On Tuesday, 4 April 2017 21:58:25 UTC+1, Luis Gonçalves wrote:
  multiplyByMatrix( outC1, outC2, outC3, outC1, outC2, outC3, xyz2rgbD65Mat );    <----------------------- This line, for me, is doing nothing


The function converts pixel values from XYZ to RGB (rec.709) color space. It is needed as all pixels are stored in XYZ in the pfs stream. 

Rafal

Reply all
Reply to author
Forward
0 new messages