Menu

#321 wrong calculation RGB gamma in YUV

open
nobody
None
7
2012-07-06
2012-07-06
alexey
No

RGB gammacorrection in filter "Picture properties" wrong calculated, if input colorspace is YUV.

See attachment for image, in which you see difference between processing in RGB, and YUV colorspace, and source videos in RGB and YUV colorspace for test.

Discussion

  • alexey

    alexey - 2012-07-06

    image with processing in RGB and YUV

     
  • alexey

    alexey - 2012-07-06

    erroneous code in the file TimgFilterLuma.cpp

    void TimgFilterGammaRGB::processGammaYUV(...) {
    ...
    double gY = 1.0/(0.299*gammaR+0.587*gammaG+0.114*gammaB);
    double gU = 1.0/sqrt (gammaB / gammaG);
    double gV = 1.0/sqrt (gammaR / gammaG);
    for(int i=0; i<256; i++)
    {
    gammaTabYUV[0][i]=(unsigned char)(255.0*pow((i/255.0),gY));
    gammaTabYUV[1][i]=(unsigned char)(255.0*pow((i/255.0),gU));
    gammaTabYUV[2][i]=(unsigned char)(255.0*pow((i/255.0),gV));
    }
    ...
    }

    YUV can not be converted using color mapping, only RGB.
    you must convert YUV to RGB, perform gamma-processing by color mapping, and then convert RGB to YUV.

     
  • alexey

    alexey - 2012-07-06

    Video in YUV colorspace

     
  • alexey

    alexey - 2012-07-06

    Video in RGB colorspace

     
  • alexey

    alexey - 2012-07-06
    • priority: 5 --> 7
     

Log in to post a comment.