示例#1
0
void TiledBeizerCurve::setCurve(const BeizerCurve& curve)
{
    RANGERS_D(TiledBeizerCurve);
    d->curve = curve;
    calcCurve();
}
示例#2
0
void TlevelsSettings::calcMap(unsigned int map[256], int mapc[256], int inMin, int inMax, int outputLevelsMode)
{
    int fullRange = fullY;
    switch (outputLevelsMode) {
        case TrgbPrimaries::PcRGB:
            fullRange = 1;
            break;
        case TrgbPrimaries::TvRGB:
            fullRange = 0;
            break;
        case TrgbPrimaries::Invalid_RGB_range:
        default:
            break;
    }
    double a = inMin, b = inMax, c = outMin, d = outMax;
    if (a == b) {
        b += 1;
    }
    if (c == d) {
        d += 1;
    }
    double gamma = this->gamma / 100.0;
    int divisor = inMax - inMin + (inMax == inMin);
    int limitMin = fullRange ? 0 : 16, limitMax = fullRange ? 255 : 235;
    switch (mode) {
        case 0:
        case 6: // Seb's BTB&WTW
            for (int x = 0; x < 256; x++) { // original
                double i = fullRange ? x : (x - 16) * (255.0 / 219.0);
                double p = (i - inMin) / divisor;
                p = pow(limit(p, 0.0, 1.0), 1 / gamma);
                p = p * (outMax - outMin) + outMin;
                map[x] = limit(int(p), limitMin, limitMax);
            }
            break;
        case 1:
            for (int x = 0; x < 256; x++) { // Ylevels
                double i = fullRange ? x : (x - 16) * (255.0 / 219.0);
                double p = pow((i - a) / (b - a), 1 / gamma) * (d - c) + c;
                if (!fullRange) {
                    p = p * (219.0 / 255.0) + 16.5;
                }
                map[x] = limit(int(p), limitMin, limitMax);
            }
            break;
        case 2:
            for (int x = 0; x < 256; x++) // YlevelsG
                // Original script for Avisynth by Didee and Alain2
                // http://forum.doom9.org/showthread.php?p=897854
                //
                // Function YlevelsG_DarkEnh(clip clp, int a, float gamma, int b, int c, int d)
                // {
                //  wicked = "x "+string(a)+" - "+string(b)+" "+string(a)+" - / "+string(d)+" "+string(c)+" - * "+string(c)+" + x 255 / * x "+string(a)+" - "+string(b)+" "+string(a)+" - / 1 "+string(gamma)+" / ^ "+string(d)+" "+string(c)+" - * "+string(c)+" + 1 x 255 / - * +"
                //  Return( clp.mt_lut(Yexpr = wicked, U=2,V=2) )
                // }
            {
                double i = fullRange ? x : (x - 16) * (255.0 / 219.0);
                double p = ((i - a) / (b - a) * (d - c) + c) * i / 255 + (pow((i - a) / (b - a), 1 / gamma) * (d - c) + c) * (1 - i / 255);
                if (!fullRange) {
                    p = p * (219.0 / 255.0) + 16.5;
                }
                map[x] = limit(int(p), limitMin, limitMax);
            }
            break;
        case 3:
            for (int x = 0; x < 256; x++) // YlevelsS
                // Original script for Avisynth by Didee and Alain2
                //
                // Function YlevelsS_DarkEnh(clip clp, int a, float gamma, int b, int c, int d)
                // {
                //  wicked = "x "+string(a)+" - "+string(b)+" "+string(a)+" - / "+string(d)+" "+string(c)+" - * "+string(c)+" + x 162.338 / sin * x "+string(a)+" - "+string(b)+" "+string(a)+" - / 1 "+string(gamma)+" / ^ "+string(d)+" "+string(c)+" - * "+string(c)+" + 1 x 162.338 / sin - * +"
                //  Return( clp.mt_lut(Yexpr = wicked, U=2,V=2) )
                // }
            {
                double i = fullRange ? x : (x - 16) * (255.0 / 219.0);
                double p = ((i - a) / (b - a) * (d - c) + c) * sin(i / 162.338) + (pow((i - a) / (b - a), 1 / gamma) * (d - c) + c) * (1 - sin(i / 162.338));
                if (!fullRange) {
                    p = p * (219.0 / 255.0) + 16.5;
                }
                map[x] = limit(int(p), limitMin, limitMax);
            }
            break;
        case 4:
            for (int x = 0; x < 256; x++) // YlevelsC
                // Original script for Avisynth by Didee and Alain2
                //
                // Function YlevelsC_DarkEnh(clip clp, int a, float gamma, int b, int c, int d)
                // {
                //  wicked = "x "+string(a)+" - "+string(b)+" "+string(a)+" - / "+string(d)+" "+string(c)+" - * "+string(c)+" + 1 x 162.338 / cos - * x "+string(a)+" - "+string(b)+" "+string(a)+" - / 1 "+string(gamma)+" / ^ "+string(d)+" "+string(c)+" - * "+string(c)+" + x 162.338 / cos * +"
                //  Return( clp.mt_lut(Yexpr = wicked, U=2,V=2) )
                // }
            {
                double i = fullRange ? x : (x - 16) * (255.0 / 219.0);
                double p = ((i - a) / (b - a) * (d - c) + c) * (1 - cos(i / 162.338)) + (pow((i - a) / (b - a), 1 / gamma) * (d - c) + c) * cos(i / 162.338);
                if (!fullRange) {
                    p = p * (219.0 / 255.0) + 16.5;
                }
                map[x] = limit(int(p), limitMin, limitMax);
            }
            break;
        case 5:
            calcCurve(map);
            break;
            /*
               case 6: // Seb's BTB&WTW
                for (int x=0;x<256;x++)
                 {
                  //double i=fullRange?x:(x-16)*(255.0/219.0);
                  double p=(x-inMin)/divisor;
                  p=pow(limit(p,0.0,1.0),1/gamma);
                  p=p*(outMax-outMin)+outMin;
                  map[x]=limit(int(p),limitMin,limitMax);
                 }
                break;*/
    }
    if (mode != 5 && posterize != 255) {
        unsigned int stepd = 256 / (posterize - 1);
        for (unsigned int x = 0; x < 256; x++) {
            map[x] = limit(((map[x] + stepd / 2) / stepd) * stepd, 0U, 255U);
        }
    }
    mapc[0] = map[0] ? 0x400000 : 0;
    for (int x = 1 ; x < 256 ; x++) {
        mapc[x] = 0x4000 * map[x] / x;
    }
}
示例#3
0
void Channel::update()
{
	QString name(_channelSettings.name);
	ui.leName->setText(name);

	ui.cbSensor->setCurrentIndex(_channelSettings.type);

	ui.cbNote->setCurrentIndex(_channelSettings.note);

	ui.dialThreshold->setValue(_channelSettings.threshold);

	ui.btnSumScan->setChecked(_channelSettings.sum);

	ui.dialScanTime->setValue(_channelSettings.scanTime);

	ui.dialMaskTime->setValue(_channelSettings.maskTime);

	ui.cbCurveType->setCurrentIndex(_channelSettings.curve.type);

	ui.dialValue->setValue(_channelSettings.curve.value);

	ui.dialOffset->setValue(_channelSettings.curve.offset);

	ui.dialFactor->setValue(_channelSettings.curve.factor);

	auto effect = static_cast<QGraphicsDropShadowEffect*>(ui.btnSumScan->graphicsEffect());

	if(_channelSettings.sum) {
		effect->setColor(QColor(0xff9966));
	}

	else {
		effect->setColor(QColor(0, 0, 0, 0));
	}

	{
		QVector<qreal> x(128);
		QVector<qreal> y(128);

		for(auto i = 0; i < 128; ++i) {
			x[i] = i;
			y[i] = calcCurve(_channelSettings.curve, i) ;
		}

		_curvePlot->graph(0)->setData(x, y);
	}

	//{
	//  QVector<qreal> x(2);
	//  QVector<qreal> y(2);
	//
	//  x[0] = 0;
	//  x[1] = 127;
	//  y[0] = _channelSettings.threshold;
	//  y[1] = _channelSettings.threshold;

	//  _curvePlot->graph(1)->setData(x, y);
	//}

	_curvePlot->replot();
}
void smoothCurve(t_List *L_in, t_List *L_out, t_RegionStats *inside, t_RegionStats *outside,
		char *bip1, t_jit_matrix_info* in1_minfo,
		char *phi_bp, t_jit_matrix_info* phi_minfo,
		long Ng, t_int32 *gaussKernel)
{
	t_Node *nodeOut, *nodeIn, *tempNode;
	uchar val;
	long swin=0, swout=0;

	nodeOut = L_out->lastNode;

	//evolve outside
	while(nodeOut) {
		tempNode = nodeOut->prev;
		val = *(uchar *)(bip1 + nodeOut->pixel[0] + (nodeOut->pixel[1])*in1_minfo->dimstride[1]);

		//post("swI: (%d, %d): %d", nodeOut->pixel[0], nodeOut->pixel[1], calcCurve(nodeOut->pixel[0], nodeOut->pixel[1], Ng, gaussKernel, phi_bp, phi_minfo));

		if( calcCurve(nodeOut->pixel[0], nodeOut->pixel[1], Ng, gaussKernel, phi_bp, phi_minfo) < 0) {
			switch_in(L_in, L_out, nodeOut, phi_bp, phi_minfo);

			swin++;

			outside->countTemp--;
			outside->sumTemp -= (double)val;
			outside->sumSqTemp -= (double)val*(double)val;

			inside->countTemp++;
			inside->sumTemp += (double)val;
			inside->sumSqTemp += (double)val*(double)val;
		}

		nodeOut = tempNode;
	}

	cleanListInterior(L_in, phi_bp, phi_minfo);

	nodeIn = L_in->lastNode;

	//evolve inside
	while(nodeIn) {
		tempNode = nodeIn->prev;
		val = *(uchar *)(bip1 + nodeIn->pixel[0] + (nodeIn->pixel[1])*in1_minfo->dimstride[1]);

		if( calcCurve(nodeIn->pixel[0], nodeIn->pixel[1], Ng, gaussKernel, phi_bp, phi_minfo) > 0) {
			switch_out(L_in, L_out, nodeIn, phi_bp, phi_minfo);

			swout++;

			outside->countTemp++;
			outside->sumTemp += (double)val;
			outside->sumSqTemp += (double)val*(double)val;

			inside->countTemp--;
			inside->sumTemp -= (double)val;
			inside->sumSqTemp -= (double)val*(double)val;
		}

		nodeIn = tempNode;
	}

	cleanListExterior(L_out, phi_bp, phi_minfo);
}