Search code examples
matrixcolorsfilterspacegpuimage

GPUImage colorspace used for filter?


I'm using GPUImage but I asked myself what's the colorspace used with filters ? like Sepia.

I think it's XYZCIE but I have different result with OpenCV with the same matrix.

Thanks to help me !


Solution

  • The colorspace is simple RGB. Subclasses of GPUImageColorMatrixFilter, like the GPUImageSepiaFilter, work by multiplying the RGBA color vector for a pixel with a 4x4 color matrix.

    The shader code used to do this is the following:

     vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
     vec4 outputColor = textureColor * colorMatrix;
    
     gl_FragColor = (intensity * outputColor) + ((1.0 - intensity) * textureColor);
    

    The second line is where the matrix multiplication takes place. OpenCV may not apply the same matrix multiplication, or they may use a different column vs. row ordering in the matrix.