Esempio n. 1
0
void update(MMSP::grid<2,double>& grid, int steps)
{
	const MMSP::grid<2,double>& f = grid;

	MMSP::grid<2,double> u(f);
	int x0 = MMSP::x0(u);
	int x1 = MMSP::x1(u);
	int y0 = MMSP::y0(u);
	int y1 = MMSP::y1(u);

	for (int x=x0; x<x1; x++)
		for (int y=y0; y<y1; y++)
			u[x][y] = 0.0;

	FMG(u,f,1,2,2);

	MMSP::swap(grid,u);
}
Esempio n. 2
0
void StereoVar::FMG(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level)
{
    double  scale = pow(pyrScale, (double) level);
    CvSize  frmSize = cvSize((int) (u.cols * scale + 0.5), (int) (u.rows * scale + 0.5));
    Mat I1_h, I2_h, I2x_h, u_h;

    //scaling DOWN
    resize(I1, I1_h, frmSize, 0, 0, INTER_AREA);
    resize(I2, I2_h, frmSize, 0, 0, INTER_AREA);
    resize(u, u_h, frmSize, 0, 0, INTER_AREA);
    u_h.convertTo(u_h, u_h.type(), scale);
    I2x_h = diffX(I2_h);

    switch (cycle) {
        case CYCLE_O:
            VariationalSolver(I1_h, I2_h, I2x_h, u_h, level);
            break;
        case CYCLE_V:
            VCycle_MyFAS(I1_h, I2_h, I2x_h, u_h, level);
            break;
    }

    u_h.convertTo(u_h, u_h.type(), 1.0 / scale);

    //scaling UP
    resize(u_h, u, u.size(), 0, 0, INTER_CUBIC);

    I1_h.release();
    I2_h.release();
    I2x_h.release();
    u_h.release();

    level--;
    if ((flags & USE_AUTO_PARAMS) && (level < levels / 3)) {
        penalization = PENALIZATION_PERONA_MALIK;
        fi *= 100;
        flags -= USE_AUTO_PARAMS;
        autoParams();
    }
    if (flags & USE_MEDIAN_FILTERING) medianBlur(u, u, 3);
    if (level >= 0) FMG(I1, I2, I2x, u, level);
}
Esempio n. 3
0
std::vector<CFWA>LoadFwas( const char *pszFwaFile )
{
    std::vector<CFWA>fwas;
    //if constructor opens a file
    ifstream inFWAFile( pszFwaFile, ios::in );

    //exit program if ifstream could not open file
    if ( !inFWAFile ) {
        cerr << "File could not be opened" << endl;
    //    exit( 1 );
    }
    // Enter elements for first FWA 
    string FWA( "Roadless_Stevensville" );
    string FMG( "Roadless" );
    int WalkInPct = 98;
    int PumpNRoll = 0;
    int Head = 100;
    int Tail = 0;
    int Parallel = 0;
    int AttDist = 0;
    bool WaterDrops = true;
    bool Excluded = false;
    double DiscSize = 0.01;
    int ESLTime = 1440;
    int ESLSize = 300;
    double AirtoGround = 1.6;
    int WalkInDelay[6] = { 0, 0, 30, 30, 15, 15 };
    int PostContUsed[6] = { 0, 0, 20, 20, 20, 20 };
    int PostContUnused[6] = { 0, 0, 0, 0, 0, 0, };
    int PostEscape[6] = { 0, 0, 20, 20, 20, 20 };
    int ReloadDelay[5] = { 0, 20, 20, 5, 25 };
    int FirstUnitDelay = 5;
    double Diurnal[24] = {0.10, 0.10, 0.10, 0.10, 0.10, 0.10,
                          0.10, 0.10, 0.10, 0.10, 0.20, 0.40, 
                          0.70, 1.00, 1.00, 1.00, 1.00, 1.00, 
                          1.00, 1.00, 0.70, 0.50, 0.30, 0.20 };
    string ROSAdjFuel[10] = { "x", "x", "x", "x", "x", "x", "x", "x", "x", "x" };
    double ROSAdjustment[10] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
    int Index = 0;
    string DispLogicId( "FMU12" );
    double Latitude = 0;
    double Longitude = 0;

    // Read in each FWA entry from file
    while ( inFWAFile >> FWA >> FMG >> WalkInPct >> PumpNRoll >> Head >> Tail >> Parallel >> AttDist >> WaterDrops >> Excluded 
            >> DiscSize >> ESLTime >> ESLSize >> AirtoGround )    {
        for ( int i = 0; i < 6; i++ )
            inFWAFile >> WalkInDelay[i];
        for ( int i = 0; i < 6; i++ )
            inFWAFile >> PostContUsed[i];
        for ( int i = 0; i < 6; i++ )
            inFWAFile >> PostContUnused[i];
        for ( int i = 0; i < 6; i++ )
            inFWAFile >> PostEscape[i];
        for ( int i = 0; i < 5; i++ )
            inFWAFile >> ReloadDelay[i];
            inFWAFile >> FirstUnitDelay;
        for ( int i = 0; i < 24; i++ )
            inFWAFile >> Diurnal[i];
        for ( int i = 0; i < 10; i++ )
            inFWAFile >> ROSAdjFuel[i];
        for ( int i = 0; i < 10; i++ )
            inFWAFile >> ROSAdjustment[i];
        inFWAFile >> Index >> DispLogicId >> Latitude >> Longitude;

        int bp[5] = { 0,0,0,0,0 };
        int rn[13][5] = { {1,1,1,1,1},
                          {1,1,1,1,1},
                          {1,1,1,1,1},
                          {1,1,1,1,1},
                          {1,1,1,1,1},
                          {1,1,1,1,1},
                          {1,1,1,1,1},
                          {1,1,1,1,1},
                          {1,1,1,1,1},
                          {1,1,1,1,1},
                          {1,1,1,1,1},
                          {1,1,1,1,1},
                          {1,1,1,1,1} };

        CDispLogic logic("", "", 3, bp, rn );
		string FPU = "GB_ID_002";

        fwas.push_back( CFWA( FWA, FMG, WalkInPct, PumpNRoll, Head, Tail, Parallel, AttDist, WaterDrops, Excluded, DiscSize,
            ESLTime, ESLSize, AirtoGround, WalkInDelay, PostContUsed, PostContUnused, PostEscape, ReloadDelay, FirstUnitDelay, 
            Diurnal, ROSAdjFuel, ROSAdjustment, 0, logic, FPU ));
            
    }    
    return fwas;
}
Esempio n. 4
0
void StereoVar::operator ()( const Mat& left, const Mat& right, Mat& disp )
{
    CV_Assert(left.size() == right.size() && left.type() == right.type());
    CvSize imgSize = left.size();
    int MaxD = MAX(labs(minDisp), labs(maxDisp));
    int SignD = 1; if (MIN(minDisp, maxDisp) < 0) SignD = -1;
    if (minDisp >= maxDisp) {MaxD = 256; SignD = 1;}

    Mat u;
    if ((flags & USE_INITIAL_DISPARITY) && (!disp.empty())) {
        CV_Assert(disp.size() == left.size() && disp.type() == CV_8UC1);
        disp.convertTo(u, CV_32FC1, static_cast<double>(SignD * MaxD) / 256);
    } else {
        u.create(imgSize, CV_32FC1);
        u.setTo(0);
    }

    // Preprocessing
    Mat leftgray, rightgray;
    if (left.type() != CV_8UC1) {
        cvtColor(left, leftgray, CV_BGR2GRAY);
        cvtColor(right, rightgray, CV_BGR2GRAY);
    } else {
        left.copyTo(leftgray);
        right.copyTo(rightgray);
    }
    if (flags & USE_EQUALIZE_HIST) {
        equalizeHist(leftgray, leftgray);
        equalizeHist(rightgray, rightgray);
    }
    if (poly_sigma > 0.0001) {
        GaussianBlur(leftgray, leftgray, cvSize(poly_n, poly_n), poly_sigma);
        GaussianBlur(rightgray, rightgray, cvSize(poly_n, poly_n), poly_sigma);
    }

    if (flags & USE_AUTO_PARAMS) {
        penalization = PENALIZATION_TICHONOV;
        autoParams();
    }

    Mat I1, I2;
    leftgray.convertTo(I1, CV_32FC1);
    rightgray.convertTo(I2, CV_32FC1);
    leftgray.release();
    rightgray.release();

    Mat I2x = diffX(I2);

    FMG(I1, I2, I2x, u, levels - 1);

    I1.release();
    I2.release();
    I2x.release();


    disp.create( left.size(), CV_8UC1 );
    u = abs(u);
    u.convertTo(disp, disp.type(), 256 / MaxD, 0);

    u.release();
}