예제 #1
0
파일: unitTest.cpp 프로젝트: assutech/isis3
void oneInput(Isis::Buffer &b) {
 if ((b.Sample() == 1) && (b.Band() == 1)) {
   cout << "Testing one input cube ... " << endl;
   cout << "Buffer Samples:  " << b.SampleDimension() << endl;
   cout << "Buffer Lines:    " << b.LineDimension() << endl;
   cout << "Buffer Bands:    " << b.BandDimension() << endl;
   cout << endl;
 }
 cout << "Sample:  " << b.Sample() 
      << "  Line:  " << b.Line() 
      << "  Band:  " << b.Band() << endl;
}
예제 #2
0
파일: unitTest.cpp 프로젝트: assutech/isis3
void oneInAndOut (Isis::Buffer &ib, double &ob) {
	static bool firstTime = true;
  if (firstTime) {
    firstTime = false;
    cout << endl;
    cout << "Testing one input and output cube ... " << endl;
    cout << "Boxcar Samples:  " << ib.SampleDimension() << endl;
    cout << "Boxcar Lines:    " << ib.LineDimension() << endl;
    cout << "Boxcar Bands:    " << ib.BandDimension() << endl;
    cout << endl;
  }
  
  if (ib.Sample() < 1) {
    cout << "Top Left Sample:  " << ib.Sample() 
         << ", Top Left Line:  " << ib.Line() 
         << ", Top Left Band:  " << ib.Band() << endl;
  }
}
예제 #3
0
파일: unitTest.cpp 프로젝트: assutech/isis3
void oneInAndOut (Isis::Buffer &ib, Isis::Buffer &ob) {
  if ((ib.Sample() == 1) && (ib.Band() == 1)) {
    cout << endl;
    cout << "Testing one input and output cube ... " << endl;
    cout << "Buffer Samples:  " << ib.SampleDimension() << endl;
    cout << "Buffer Lines:    " << ib.LineDimension() << endl;
    cout << "Buffer Bands:    " << ib.BandDimension() << endl;
    cout << endl;
  }
  cout << "Sample:  " << ib.Sample() 
       << "  Line:  " << ib.Line() 
       << "  Band:  " << ib.Band() << endl;

  if ((ib.Sample() != ob.Sample()) || 
      (ib.Line() != ob.Line()) ||
      (ib.Band() != ob.Band())) {
    cout << "Bogus error #1" << endl;
  }
}
예제 #4
0
void writeCubeOutput(Isis::Buffer &data) {
    // The framelet number is necessary for deciding which cube to put the framelet's data in, EVEN or ODD.
    //   Getting the framelet is just a matter of (line / (height of framelet))
    int framelet =  (data.Line()-1) / (filterHeight * numFilters);

    // The filter number is important for telling us which band we're processing. This can be calculated with
    //   (line / (height of filter)), very similar to the framelet calculation.
    int filter = (data.Line()-1) / filterHeight;

    // The band number is the filter modulus the number of filters.
    int band = filter % numFilters;

    // If flip is -1, then we've got to auto-detect it still. The auto-detect works by first reading in the first two
    //   framelets into two bricks, the size of a framelet in the output. Then a correlation is done between the end of
    //   the first framelet, first band, and the ends of the second framelet, first band. Once the flip has
    //   been determined (yes or no), the two framelets in memory are written into the output cube and the program continues
    //   normal execution from then on.
    if(flip == -1 && framelet < 2) {
        // If we're in the first two framelets, just read into memory.
        if(currentLine[band] <= filterHeight) {
            for(int i = 0; i < data.SampleDimension(); i++) {
                (*flipDataBrick1)[flipDataBrick1->Index(i, currentLine[band] - 1, band)] = data[i];
            }
        }
        else {
            for(int i = 0; i < data.SampleDimension(); i++) {
                (*flipDataBrick2)[flipDataBrick2->Index(i, currentLine[band] - filterHeight - 1, band)] = data[i];
            }
        }
    }
    // Not in the first two framelets, flip is unknown, we should figure it out!
    else if(flip == -1) {
        // We'll do two correlations against baseLine, which is the last line of the first framelet's first band
        Isis::Brick baseLine(flipDataBrick2->SampleDimension(), 1, 1, Isis::Real);
        Isis::Brick firstLine(flipDataBrick2->SampleDimension(), 1, 1, Isis::Real);
        Isis::Brick lastLine(flipDataBrick2->SampleDimension(), 1, 1, Isis::Real);

        // Populate our lines that will be correlated
        for(int i = 0; i < flipDataBrick2->SampleDimension(); i++) {
            baseLine[i] = (*flipDataBrick1)[flipDataBrick2->Index(i, flipDataBrick2->LineDimension()-1,0)];
            firstLine[i] = (*flipDataBrick2)[i];
            lastLine[i]  = (*flipDataBrick2)[flipDataBrick2->Index(i, flipDataBrick2->LineDimension()-1,0)];
        }

        // The MultivariateStatistics will do our correlation for us. Pass it the first set of data, correlate,
        //   remove the data, pass it the second set and correlate. If the second correlation is better, flip.
        MultivariateStatistics stats;
        stats.AddData(baseLine.DoubleBuffer(), firstLine.DoubleBuffer(), flipDataBrick1->SampleDimension());
        double corr1 = fabs(stats.Correlation());
        stats.RemoveData(flipDataBrick1->DoubleBuffer(), firstLine.DoubleBuffer(), flipDataBrick1->SampleDimension());
        stats.AddData(baseLine.DoubleBuffer(), lastLine.DoubleBuffer(), flipDataBrick1->SampleDimension());
        double corr2 = fabs(stats.Correlation());

        // Failure = No Flip
        if(Isis::IsSpecial(corr1) || Isis::IsSpecial(corr2) || corr1 >= corr2) {
            flip = 0;
        }
        else {
            flip = 1;
        }

        // Write the two bricks in memory to the output
        writeFlipBricks();
    }

    // We're going to write every cube, regardless of if it's the right cube. We'll be populating the extra data with nulls.
    for(unsigned int cube = 0; (flip != -1) && (cube < outputCubes.size()); cube++) {
        // The data will be copied into a brick, and the brick written. We do this so we can set the position to write
        //   the output data.
        Brick output(data.SampleDimension(), data.LineDimension(), 1, Isis::Real);

        // currentLine[] is 1-based
        if(flip == 0) {
            output.SetBasePosition(1, currentLine[band] + padding[band], band+1);
        }
        else if(flip == 1) {
            int outLine = outputCubes[cube]->Lines() - filterHeight -
                          ((currentLine[band] - 1) / filterHeight) * filterHeight + (currentLine[band]-1) % filterHeight;

            output.SetBasePosition(1, outLine+1 - padding[band], band+1);
        }

        // If the 1-based framelet number mod the output cubes equals the current cube, it's the proper cube to use.
        // Flipped data can end up with even/odd flipped, and indeed probably will, but this isn't a concern.
        if((framelet+1) % outputCubes.size() == cube) {
            for(int i = 0; i < data.size(); i++) {
                output[i] = data[i];
            }
        }
        else {
            for(int i = 0; i < data.size(); i++) {
                output[i] = Isis::Null;
            }
        }

        // Data is in our brick, let's write it into the cube.
        outputCubes[cube]->Write(output);
    }

    currentLine[band] ++;
}