Personal tools

Views

Quantization hydra

From Adobe Labs

[edit]

Quantization source code

/*****************************************************************************
 *
 * Author: Joa Ebert
 * http://blog.je2050.de
 * Contact: j -at- je2050.de
 *
 *****************************************************************************/
kernel ColorQuantization
<   nameSpace:          "popforge::ImageProcessing";
    vendor:             "Joa Ebert";
    version:            1;
    description:        "Color quantization reduces the dynamic range in an image.";
>
{
    parameter float3 levels
    <
        minValue:       float3(0.0);
        maxValue:       float3(256.0);
        defaultValue:   float3(6.0);
        description:    "The number of allowed values per channel.";
    >;
    
    void evaluatePixel(in image3 source, out pixel3 result)
    {
        pixel3 color = sampleLinear(source,outCoord());
        result = color - mod(color, float3(1.0) / levels);
    }
}
Retrieved from "http://labs.adobe.com/wiki/index.php/Quantization_hydra"