Personal tools

Views

Sepia hydra

From Adobe Labs

[edit]

Sepia source code

/*****************************************************************************
 *
 * Author: Joa Ebert
 * http://blog.je2050.de
 * Contact: j -at- je2050.de
 *
 *****************************************************************************/
kernel Sepia
<   nameSpace:          "popforge::ImageProcessing";
    vendor:             "Joa Ebert";
    version:            1;
    description:        "A good looking sepia filter using Y transform";
>
{
    void evaluatePixel(in image3 source, out pixel3 result)
    {
        pixel3 color = sampleLinear( source, outCoord() );
        float y = 0.299 * color.r + 0.587 * color.g + 0.114 * color.b;
        
        // use min/max instead of if's
        float r = min(1.0, y + 0.19);
        float g = max(0.0, y - 0.055);
        float b = max(0.0, y - 0.22);
        
        result = pixel3(r,g,b);
    }
}
Retrieved from "http://labs.adobe.com/wiki/index.php/Sepia_hydra"