Exemplo n.º 1
0
    ColorCorrecterBase(OFX::ImageEffect &instance,const OFX::RenderArguments &args)
    : OFX::ImageProcessor(instance)
    , _srcImg(0)
    , _maskImg(0)
    , _premult(false)
    , _premultChannel(3)
    , _doMasking(false)
    , _mix(1.)
    , _maskInvert(false)
    {
        // build the LUT
        OFX::ParametricParam  *lookupTable = instance.fetchParametricParam(kParamColorCorrectToneRanges);
        assert(lookupTable);
        for (int curve = 0; curve < 2; ++curve) {
            for (int position = 0; position <= LUT_MAX_PRECISION; ++position) {
                // position to evaluate the param at
                double parametricPos = double(position)/LUT_MAX_PRECISION;

                // evaluate the parametric param
                double value = lookupTable->getValue(curve, args.time, parametricPos);

                // set that in the lut
                _lookupTable[curve][position] = (float)std::max(0.,std::min(value*LUT_MAX_PRECISION+0.5, double(LUT_MAX_PRECISION)));
            }
        }
    }
Exemplo n.º 2
0
    ColorCorrecter(OFX::ImageEffect &instance, const OFX::RenderArguments &args, bool supportsParametricParameter)
    : ColorCorrecterBase(instance,args)
    {
        // build the LUT
        OFX::ParametricParam  *lookupTable = 0;
        if (supportsParametricParameter) {
            lookupTable = instance.fetchParametricParam(kParamColorCorrectToneRanges);
        }
        for (int curve = 0; curve < 2; ++curve) {
            for (int position = 0; position <= LUT_MAX_PRECISION; ++position) {
                // position to evaluate the param at
                double parametricPos = double(position)/LUT_MAX_PRECISION;

                // evaluate the parametric param
                double value;
                if (lookupTable) {
                    value = lookupTable->getValue(curve, args.time, parametricPos);
                } else if (curve == 0) {
                    if (parametricPos < 0.09) {
                        value = 1. - parametricPos/0.09;
                    } else {
                        value = 0.;
                    }
                } else {
                    assert(curve == 1);
                    if (parametricPos <= 0.5) {
                        value = 0.;
                    } else {
                        value = (parametricPos - 0.5) / 0.5;
                    }
                }
                // set that in the lut
                _lookupTable[curve][position] = (float)clamp<PIX>(value, maxValue);
            }
        }

    }