Martin Chan
Martin Chan

Reputation: 5

adobe pixel bender(.pbk) range of colors between two colors

I am new to pixel bender.

I am programming with as3. I want to do a green screen calibrator. I have manage to turn one rgb(Hex) color alpha to 0 with shader filter (with online search):

{
    input image4 src;
    output pixel4 dst;

    parameter float3 keyColor0;

    parameter float tolerance
    <
        minValue: 0.0;
        maxValue: 3.0;
        defaultValue: 0.02;
    >;

    parameter float ramp
    <
        minValue: 0.0;
        maxValue: 1.0;
        defaultValue: 0.005;
    >;

     parameter float gamma
    <
        minValue: 0.0;
        maxValue: 10.0;
        defaultValue: 1.00;
    >;

    void
    evaluatePixel()
    {
        dst = sampleNearest(src,outCoord());
        float diff = length( dst.rgb - keyColor0);
        if ( diff < tolerance )
        {
            dst.a = 0.0;
        } else if ( diff < tolerance + ramp )
        {
            dst.a = pow( (diff - tolerance) / ramp, gamma );
        }            
    }
}

But, What I would like to do is to give it two rgb colors and it will make all the colors between the two given rgb(Hex) colors to set alpha 0 as well.

For example I pick a range of colors from a image. It is a set of difference green colors, then I find the min and max out of the set of colors by using HSV.

With the min and max, I would like to set all colors between the two colors to alpha 0.

Thanks

Upvotes: 0

Views: 132

Answers (0)

Related Questions