Exemple #1
0
/** 
 * This method reads in the cube file line by line and prints 
 * out the DN value of each non-null pixel. 
 * 
 * @param in
 */
void writeAscii (Isis::Buffer &in) {
  bool notNull= false; 
  int index = in.size() - 1;
  for (int i=0; i<in.size(); i++) {
    if(in[index -i] > 0) {
      cout <<"Band: " << in.Band() << " DN: " << in[index -i] << " ";
      notNull = true;
    }   
  }
  if(notNull) {
    cout << std::endl;
  }
}
Exemple #2
0
// Call Operate once per pixel to get the interest for every pixel in the input cube.
void Operate(Isis::Buffer &in, Isis::Buffer &out) {
  try {
    int sample = in.Sample();
    int line = in.Line();

    iop->Operate(cube, sample, line);


    out[0] = iop->InterestAmount();

  } catch (iException &e) {
    e.Report();
  }
}
Exemple #3
0
void oneInput(Isis::Buffer &b) {
  if((b.Line() == 1) && (b.Sample() == 1)) {
    cout << "Testing one input cube ... " << endl;
    cout << "Buffer Samples:  " << b.size() << 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;
}
Exemple #4
0
void readValues (Isis::Buffer &in) {
  //int index = in.size() - 1;
  
  for (int i=0; i<in.size(); i++) {
    vimsValues.push_back(in[i]);
  } 
  //if(in.Band() != 96){
    //vimsValues.clear();
  //}
   
}
Exemple #5
0
void WriteOutput(Isis::Buffer &buf) {
  LineManager outLines(*outCube);

  if(lineInFile.size()) {
    for(int i = 0; i < outLines.size(); i++) {
      outLines[i] = Isis::Null;
    }

    while(!lineInFile[(buf.Line()+numLinesSkipped) % lineInFile.size()]) {
      outLines.SetLine(buf.Line() + numLinesSkipped, buf.Band());
      outCube->write(outLines);
      numLinesSkipped ++;
    }
  }

  outLines.SetLine(buf.Line() + numLinesSkipped, buf.Band());

  // outLines.Copy(buf); doesn't work because the raw buffers don't match
  for(int i = 0; i < outLines.size(); i++)
    outLines[i] = buf[i];

  outCube->write(outLines);
}
Exemple #6
0
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;
  }
}
Exemple #7
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] ++;
}
Exemple #8
0
void oneInAndOut(Isis::Buffer &ib, Isis::Buffer &ob) {
  if((ib.Line() == 1) && (ib.Sample() == 1)) {
    cout << endl;
    cout << "Testing one input and output cube ... " << endl;
    cout << "Buffer Samples:  " << ib.size() << 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;
  }
}
Exemple #9
0
void twoInAndOut (vector<Isis::Buffer *> &ib, vector<Isis::Buffer *> &ob) {
  static bool firstTime = true;
  if (firstTime) {
    firstTime = false;
    cout << "Testing two input and output cubes ... " << endl;
    cout << "Number of input cubes:   " << ib.size() << endl;
    cout << "Number of output cubes:  " << ob.size() << endl;
    cout << endl;
  }

  Isis::Buffer *inone = ib[0];
  Isis::Buffer *intwo = ib[1];
  Isis::Buffer *outone = ob[0];
  Isis::Buffer *outtwo = ob[1];
  
  cout << "Sample:  " << inone->Sample() << ":" << intwo->Sample() 
       << "  Line:  " << inone->Line() << ":" << intwo->Line()
       << "  Band:  " << inone->Band() << ":" << intwo->Band() << endl;

  if ((inone->Sample() != intwo->Sample()) || 
      (inone->Line() != intwo->Line())) {
    cout << "Bogus error #1" << endl;
  }

  if ((inone->Sample() != outone->Sample()) || 
      (inone->Line() != outone->Line()) ||
      (inone->Band() != outone->Band())) {
    cout << "Bogus error #2" << endl;
  }
  
  if ((outone->Sample() != outtwo->Sample()) || 
      (outone->Line() != outtwo->Line()) ||
      (outone->Band() != outtwo->Band())) {
    cout << "Bogus error #3" << endl;
  }
}