Exemplo n.º 1
0
void vp9_init_quant_tables() {
  int i, val = 4;

  // A "real" q of 1.0 forces lossless mode.
  // In practice non lossless Q's between 1.0 and 2.0 (represented here by
  // integer values from 5-7 give poor rd results (lower psnr and often
  // larger size than the lossless encode. To block out those "not very useful"
  // values we increment the ac and dc q lookup values by 4 after position 0.
  ac_qlookup[0] = val;
  dc_qlookup[0] = val;
  val += 4;

  for (i = 1; i < QINDEX_RANGE; i++) {
    const int ac_val = val;

    val = (int)(val * 1.01975);
    if (val == ac_val)
      ++val;

    ac_qlookup[i] = (int16_t)ac_val;
    dc_qlookup[i] = (int16_t)MAX(ACDC_MIN, poly3(0.000000305, -0.00065, 0.9,
                                                 0.5, ac_val));
  }
}
Exemplo n.º 2
0
void skeleton_mul::smoothEachBranch() {
	smoothedBrchPts.clear() ;
	smoothedBrchPts.resize(brchPts.size()) ;
	for( int i=0; i<brchPts.size(); ++i ){
		if( brchPts[i].size()< 4 ){
			while( brchPts[i].size() < 4 ){
				std::vector<Point3f> tmp ;
				for( int j=0; j< brchPts[i].size()-1; ++j ){
					tmp.push_back( brchPts[i][j] ) ;
					tmp.push_back( (brchPts[i][j]+brchPts[i][j+1])/2 ) ;

				}
				tmp.push_back( brchPts[i].back() ) ;

				brchPts[i] = tmp ;
			}
		}

		std::vector<double> x, y, z, t ;
		for( int j=0; j<brchPts[i].size(); ++j){
			x.push_back(brchPts[i][j].X() );
			y.push_back(brchPts[i][j].Y() );
			z.push_back(brchPts[i][j].Z() );
			t.push_back( (double)j/(brchPts[i].size()-1) ) ;
		}

		Spline3Interp poly1( t, x);
		poly1.calcCoefs();
		std::vector<double> px,py, pz ;
		for( double t=0.0; t<1.0; t+=0.0005 )
			px.push_back(poly1.evaluate(t)) ;
		px.push_back(poly1.evaluate(1.0)) ;


		Spline3Interp poly2( t, y);
		poly2.calcCoefs();
		for( double t=0.0; t<1.0; t+=0.0005 )
			py.push_back(poly2.evaluate(t)) ;
		py.push_back(poly2.evaluate(1.0)) ;

		Spline3Interp poly3( t, z);
		poly3.calcCoefs();
		for( double t=0.0; t<1.0; t+=0.0005 )
			pz.push_back(poly3.evaluate(t)) ;
		pz.push_back(poly3.evaluate(1.0)) ;

		for( int id=0; id<px.size(); ++id )
			smoothedBrchPts[i].push_back( Point3f(px[id], py[id], pz[id]) ) ;

	}

	for( int i=0; i<smoothedBrchPts.size() ; ++i ){
		for( int j=1; j<smoothedBrchPts[i].size()-1; ++j ){
			if( (smoothedBrchPts[i][j-1] - smoothedBrchPts[i][j]).Norm() < ReconstructorPara::branchSampleStep ){
				smoothedBrchPts[i].erase( smoothedBrchPts[i].begin()+j) ;
				j-- ;
			}

			if( (smoothedBrchPts[i][smoothedBrchPts[i].size()-1] - smoothedBrchPts[i][smoothedBrchPts[i].size()-2]).Norm() <   ReconstructorPara::branchSampleStep * 0.5)
					smoothedBrchPts[i].erase( smoothedBrchPts[i].begin()+smoothedBrchPts[i].size()-2) ;
		}
	}
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
    //check fit
    printf("Polynomial fit test:\n");
    std::vector<float> x, y;

    for(int i = 0; i < 10; i++) {
        float p_x = float(i);
        float p_y = 3.0f * p_x * p_x + 2.0f * p_x + 1.0f;
        x.push_back(p_x);
        y.push_back(p_y);
    }

    pic::Polynomial poly;
    poly.fit(x, y, 2);

    poly.print();

    printf("p(4.0f) = %f\n", poly.eval(4.0f));

    float roots[2];
    bool bReal = poly.getAllRoots(roots);

    if(bReal) {
        printf("Roots: %f %f\n", roots[0], roots[1]);
    } else {
        printf("No Real roots!\n");
    }

    printf("\n\n");

    printf("Second order polynomial test:\n");
    float tmp[] = {1.0f, -3.0f, 0.5f};
    pic::Polynomial poly2(tmp, 3);
    poly2.print();

    printf("p(0.0f) = %f\n", poly2.eval(0.0f));
    printf("dp(1.0f) = %f\n", poly2.dEval(1.0f));

    bReal = poly2.getRoots(roots);

    if(bReal) {
        printf("Roots: %f %f\n", roots[0], roots[1]);
    } else {
        printf("No Real roots!\n");
    }

    printf("\n\n");

    printf("Third order polynomial test:\n");
    float tmp3[] = {-6.0f, 11.0f, -6.0f, 1.0f};
    pic::Polynomial poly3(tmp3, 4);
    poly3.print();

    float r;
    auto poly3_2 = poly3.horner(3.0f, r);    
    printf("H: %s R: %f\n", poly3_2.toString().c_str(), r);;

    printf("p(1.0f) = %f\n", poly3.eval(1.0f));
    printf("dp(1.0f) = %f\n", poly3.dEval(1.0f));

    float roots3[3];
    bReal = poly3.getAllRoots(roots3);

    if(bReal) {
        printf("Roots: %f %f %f\n", roots3[0], roots3[1], roots3[2]);
    } else {
        printf("No Real roots!\n");
    }

    printf("\n\n");

    printf("Foruth order polynomial test:\n");
    float tmp4[] = {24, -50.0f, 35.0f, -10.0f, 1.0f};
    pic::Polynomial poly4(tmp4, 5);
    poly4.print();

    auto poly4_2 = poly4.horner(3.0f, r);
    printf("H: %s R: %f\n", poly4_2.toString().c_str(), r);;

    printf("p(1.0f) = %f\n", poly4.eval(1.0f));
    printf("dp(1.0f) = %f\n", poly4.dEval(1.0f));

    float roots4[4];
    bReal = poly4.getAllRoots(roots4);

    if(bReal) {
        printf("Roots: %f %f %f %f\n", roots4[0], roots4[1], roots4[2], roots4[3]);
    } else {
        printf("No Real roots!\n");
    }

    return 0;
}