This Pixel Bender kernel progressively desaturates an image by blending each pixel with a grayscale version, where colorization controls how much original color remains.

// ColorizationFilter.pbk

<languageVersion : 1.0;>

kernel ColorizationFilter
<   namespace : "net.jsloop";
    vendor : "jsloop.net";
    author : "Jaseem V V";
    version : 1;
    description : "Colorization filter";
>
{
    input image4 src;
    output pixel4 dst;
    
    parameter float colorization
    <
        minValue: 0.0;
        maxValue: 1.0;
        defaultValue: 0.0;
    >;

    void
    evaluatePixel()
    {
        float4 pixel = sampleNearest(src, outCoord());
        float4 grayPixel;
        
        grayPixel.r = pixel.r * .11 + pixel.g * .33 + pixel.b * .55;
        grayPixel.g = grayPixel.r;
        grayPixel.b = grayPixel.r;
        grayPixel.a = 1.0;

        dst = mix(pixel, grayPixel, (1.0 - colorization));
    }
}

This Pixel Bender kernel converts a color image to grayscale by replacing each pixel’s RGB values with its perceived luminance while preserving transparency.

// GreyscaleFilter.pbk

<languageVersion : 1.0;>

kernel GreyscaleFilter
<   namespace : "net.jsloop";
    vendor : "jsloop.net";
    author : "Jaseem V V";
    version : 1;
    description : "Filter for converting an image to greyscale";
>
{
    input image4 src;
    output pixel4 dst;

    void
    evaluatePixel()
    {
        dst = sampleNearest(src,outCoord());

        // Algorithm from ITU-R Recommendation BT.709
        // http://local.wasp.uwa.edu.au/~pbourke/texture_colour/imageprocess/
        float avg = 0.2125 * dst.r + 0.7154 * dst.g + 0.0721 * dst.b;
        dst = float4(avg, avg, avg, dst.a);
    }
}

This Pixel Bender filter multiplies each pixel’s red, green, blue, and alpha values by configurable factors, allowing independent control over color intensity and transparency.

// RGBAChannelFilter.pbk

<languageVersion : 1.0;>

kernel RGBAChannelFilter
<   namespace : "net.jsloop";
    vendor : "jsloop.net";
    author : "Jaseem V V";
    version : 1;
    description : "Filter for changing Red, Green, Blue and Alpha channels of a picture";
>
{
    input image4 src;
    output pixel4 dst;

    parameter float red
    <
        minValue: -100.0;
        maxValue: 100.0;
        defaultValue: 1.0;
    >;
    
    parameter float green
    <
        minValue: -100.0;
        maxValue: 100.0;
        defaultValue: 1.0;
    >;
    
    parameter float blue
    <
        minValue: -100.0;
        maxValue: 100.0;
        defaultValue: 1.0;
    >;
    
    parameter float alpha
    <
        minValue: 0.0;
        maxValue: 1.0;
        defaultValue: 1.0;
    >;
    
    void
    evaluatePixel()
    {
        pixel4 p = sampleNearest(src, outCoord());
        p.r *= red;
        p.g *= green;
        p.b *= blue;
        p.a *= alpha;
        dst = p;
        
    }
}