当前位置: 首页>>代码示例>>C++>>正文


C++ Cube::Samples方法代码示例

本文整理汇总了C++中Cube::Samples方法的典型用法代码示例。如果您正苦于以下问题:C++ Cube::Samples方法的具体用法?C++ Cube::Samples怎么用?C++ Cube::Samples使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cube的用法示例。


在下文中一共展示了Cube::Samples方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: IsisMain

void IsisMain() {
  latLonGrid = NULL;

  // We will be processing by line
  ProcessByLine p;
  Cube *icube = p.SetInputCube("FROM");

  UserInterface &ui = Application::GetUserInterface();
  string mode = ui.GetString("MODE");

  outline = ui.GetBoolean("OUTLINE");

  inputSamples = icube->Samples();
  inputLines   = icube->Lines();

  // Line & sample based grid
  if(mode == "IMAGE") { 
    p.SetOutputCube ("TO");
    baseLine = ui.GetInteger("BASELINE"); 
    baseSample = ui.GetInteger("BASESAMPLE"); 
    lineInc = ui.GetInteger("LINC"); 
    sampleInc = ui.GetInteger("SINC"); 
    p.StartProcess(imageGrid);
    p.EndProcess();
  }
  // Lat/Lon based grid
  else {
    CubeAttributeOutput oatt("+32bit");
    p.SetOutputCube (ui.GetFilename("TO"), oatt, icube->Samples(), 
                     icube->Lines(), icube->Bands());
  
    baseLat = ui.GetDouble("BASELAT");
    baseLon = ui.GetDouble("BASELON");
    latInc = ui.GetDouble("LATINC");
    lonInc = ui.GetDouble("LONINC");

    UniversalGroundMap *gmap = new UniversalGroundMap(*icube);
    latLonGrid = new GroundGrid(gmap, icube->Samples(), icube->Lines());

    Progress progress;
    progress.SetText("Calculating Grid");

    latLonGrid->CreateGrid(baseLat, baseLon, latInc, lonInc, &progress);

    p.StartProcess(groundGrid);
    p.EndProcess();

    delete latLonGrid;
    latLonGrid = NULL;

    delete gmap;
    gmap = NULL;
  }
}
开发者ID:assutech,项目名称:isis3,代码行数:54,代码来源:grid.cpp

示例2: init

/**
 * @brief Initializes the object by computing all calibration statistics
 * 
 * This method validates the input file, reads labels for needed values
 * and computes calibration statistics for data reduction.
 * 
 * @param [in] (CubeInfo &) cube Opened cube where label and ancillary data
 *                               is read from
 */
  void HiImageClean::init(Cube &cube) {

    _lines = cube.Lines();
    _samples = cube.Samples();
    _lastGoodLine = _lines - 1;
    _totalMaskNulled = _totalDarkNulled = 0;

    PvlGroup &instrument = cube.GetGroup("Instrument");

// It may be too late and a non-issue by this time, but should check to ensure
// this is a valid HiRISE image
    iString instId = (std::string) instrument["InstrumentId"];
    if (instId.UpCase() != "HIRISE") {
      string message = "Image must be a HiRISE image (InstrumentId != HIRISE)";
      iException::Message(iException::User, message, _FILEINFO_);
    }

// Extract what is needed
    _binning = instrument["Summing"];
    _tdi = instrument["Tdi"];
    _cpmm = instrument["CpmmNumber"];
    _channelNo = instrument["ChannelNumber"];

//  Initialize all HiRISE calibration blobs
    _calimg  = blobvert(HiCalibrationImage(cube));
    _calbuf  = blobvert(HiCalibrationBuffer(cube));
    _caldark = blobvert(HiCalibrationDark(cube));
    _ancbuf  = blobvert(HiAncillaryBuffer(cube));
    _ancdark = blobvert(HiAncillaryDark(cube));

//  Compute statistics from blobs
    computeStats();
    return;
  }
开发者ID:assutech,项目名称:isis3,代码行数:43,代码来源:HiImageClean.cpp

示例3: ComputePixRes

//Helper function to get camera resolution.
void ComputePixRes () {
  Process p;
  UserInterface &ui = Application::GetUserInterface();
  Cube *latCube = p.SetInputCube("LATCUB");
  Cube *lonCube = p.SetInputCube("LONCUB");
  Brick latBrick(1,1,1,latCube->PixelType());
  Brick lonBrick(1,1,1,lonCube->PixelType());
  latBrick.SetBasePosition(1,1,1);
  latCube->Read(latBrick);

  lonBrick.SetBasePosition(1,1,1);
  lonCube->Read(lonBrick);
      
  double a = latBrick.at(0) * PI/180.0;
  double c = lonBrick.at(0) * PI/180.0;
  
  latBrick.SetBasePosition(latCube->Samples(),latCube->Lines(),1);
  latCube->Read(latBrick);

  lonBrick.SetBasePosition(lonCube->Samples(),lonCube->Lines(),1);     
  lonCube->Read(lonBrick);

  double b = latBrick.at(0) * PI/180.0;
  double d = lonBrick.at(0) * PI/180.0;

  double angle = acos(cos(a) * cos(b) * cos(c - d) + sin(a) * sin(b));
  angle *= 180/PI;

  double pixels = sqrt(pow(latCube->Samples() -1.0, 2.0) + pow(latCube->Lines() -1.0, 2.0));

  p.EndProcess();

  ui.Clear("RESOLUTION");
  ui.PutDouble("RESOLUTION", pixels/angle);

  ui.Clear("PIXRES");
  ui.PutAsString("PIXRES","PPD");
}
开发者ID:assutech,项目名称:isis3,代码行数:39,代码来源:nocam2map.cpp

示例4: IsisMain

void IsisMain() {
  ProcessRubberSheet p;

  // Open the input cube
  Cube *icube = p.SetInputCube ("FROM");

  // Set up the transform object
  UserInterface &ui = Application::GetUserInterface();
  Transform *transform = new Rotate(icube->Samples(), icube->Lines(),
                                        ui.GetDouble("DEGREES"));

  // Determine the output size
  int samples = transform->OutputSamples();
  int lines = transform->OutputLines();

  // Allocate the output file
  p.SetOutputCube ("TO", samples, lines, icube->Bands());

  // Set up the interpolator
  Interpolator *interp;
  if (ui.GetString("INTERP") == "NEARESTNEIGHBOR") {
    interp = new Interpolator(Interpolator::NearestNeighborType);
  }
  else if (ui.GetString("INTERP") == "BILINEAR") {
    interp = new Interpolator(Interpolator::BiLinearType);
  }
  else if (ui.GetString("INTERP") == "CUBICCONVOLUTION") {
    interp = new Interpolator(Interpolator::CubicConvolutionType);
  }
  else {
    string msg = "Unknow value for INTERP [" +
                 ui.GetString("INTERP") + "]";
    throw iException::Message(iException::Programmer,msg,_FILEINFO_);
  }

  p.StartProcess(*transform, *interp);
  p.EndProcess();

  delete transform;
  delete interp;
}
开发者ID:assutech,项目名称:isis3,代码行数:41,代码来源:rotate.cpp

示例5: IsisMain

void IsisMain() {
  // We will be processing by line
  ProcessByLine p;

  // Setup the input and output cubes
  Cube *icube = p.SetInputCube("FROM");
  p.SetOutputCube ("TO");

  // Override the defaults if the user entered a value
  UserInterface &ui = Application::GetUserInterface();
  top = ui.GetInteger ("TOP");
  bottom = ui.GetInteger ("BOTTOM");
  lleft = ui.GetInteger ("LEFT");
  rright = ui.GetInteger ("RIGHT");

  //  Will anything be trimmed from the cube?
  bool notrim = false;
  if (top == 0 && bottom == 0 && lleft == 0 && rright == 0) {
    notrim = true;
  }

  //  Adjust bottom and right
  bottom = icube->Lines() - bottom;
  rright = icube->Samples() - rright;

  // Start the processing
  p.StartProcess(trim);
  p.EndProcess();

  //The user didn't trim anything
  if (notrim == true) {
    string message = "No trimming was done-output equals input file";
    throw iException::Message(iException::User,message,_FILEINFO_);
  }
	   
}
开发者ID:assutech,项目名称:isis3,代码行数:36,代码来源:trim.cpp

示例6: IsisMain


//.........这里部分代码省略.........
    Pvl inStats (ui.GetFilename("INSTATS"));
    PvlObject &equalInfo = inStats.FindObject("EqualizationInformation");

    // Make sure each file in the instats matches a file in the fromlist
    if (imageList.size() > (unsigned)equalInfo.Groups()-1) {
      std::string msg = "Each input file in the FROM LIST must have a ";
      msg += "corresponding input file in the INPUT STATISTICS.";
      throw iException::Message(iException::User,msg,_FILEINFO_);
    }

    // Check that each file in the FROM LIST is present in the INPUT STATISTICS
    for (unsigned i = 0; i < imageList.size(); i++) {
      std::string fromFile = imageList[i];
      bool foundFile = false;
      for (int j = 1; j < equalInfo.Groups(); j++) {
	PvlGroup &normalization = equalInfo.Group(j);
	std::string normFile  = normalization["Filename"][0];
	if (fromFile == normFile) {

	  // Store the index in INPUT STATISTICS file corresponding to the
	  // current FROM LIST file
	  normIndices.push_back(j);
	  foundFile = true;
	}
      }
      if (!foundFile) {
	std::string msg = "The from list file [" + fromFile +
		 "] does not have any corresponding file in the stats list.";
	throw iException::Message(iException::User,msg,_FILEINFO_);
      }
    }
  }

  // Apply the correction to the images if the user wants this done
  if (processOpt != "CALCULATE") {
    iString maxCubeStr ((int)imageList.size());
    for (int img=0; img<(int)imageList.size(); img++) {
      // Set up for progress bar
      ProcessByLine p;
      iString curCubeStr (img+1);
      p.Progress()->SetText("Equalizing Cube " + curCubeStr + " of " + maxCubeStr);

      // Open input cube
      CubeAttributeInput att;
      const std::string inp = imageList[img];
      Cube *icube = p.SetInputCube(inp, att);

      // Establish the output file depending upon whether or not a to list
      // was entered
      std::string out;
      if (ui.WasEntered("TOLIST")) {
	out = outList[img];
      }
      else {
	Filename file = imageList[img];
	out = file.Path() + "/" + file.Basename() + ".equ." + file.Extension();
      }

      // Allocate output cube
      CubeAttributeOutput outAtt;
      p.SetOutputCube(out,outAtt,icube->Samples(),icube->Lines(),icube->Bands());

      // Apply gain/offset to the image
      g_imageIndex = img;
      if (processOpt == "APPLY") {

	// Apply correction based on pre-determined statistics information
	Pvl inStats (ui.GetFilename("INSTATS"));
	PvlObject &equalInfo = inStats.FindObject("EqualizationInformation");
	PvlGroup &normalization = equalInfo.Group(normIndices[g_imageIndex]);
	gains.clear();
	offsets.clear();
	avgs.clear();

	// Get and store the modifiers for each band
	for (int band = 1; band < normalization.Keywords(); band++) {
	  gains.push_back(normalization[band][0]);
	  offsets.push_back(normalization[band][1]);
	  avgs.push_back(normalization[band][2]);
	}
	p.StartProcess(ApplyViaFile); 
      }
      else {

	// Apply correction based on the statistics gathered in this run
	p.StartProcess(ApplyViaObject);
      }
      p.EndProcess();
    }
  }
  
  // Clean-up for batch list runs
  for (unsigned int o=0; o<g_oNormList.size(); o++) delete g_oNormList[o];
  g_oNormList.clear();
  g_overlapList.clear();
  normIndices.clear();
  gains.clear();
  offsets.clear();
  avgs.clear();
}
开发者ID:assutech,项目名称:isis3,代码行数:101,代码来源:equalizer.cpp

示例7: IsisMain

// Main program
void IsisMain(){
  
  // Create an object for exporting Isis data
  ProcessExport p;
  // Open the input cube
  Cube *icube = p.SetInputCube("FROM");
 
  // Conform to the Big-Endian format for FITS
  if(IsLsb()) p.SetOutputEndian(Isis::Msb);

  // Generate the name of the fits file and open it
  UserInterface &ui = Application::GetUserInterface();
    
  // specify the bits per pixel
  string bitpix;
  if (ui.GetString ("BITTYPE") == "8BIT") bitpix = "8";
  else if (ui.GetString ("BITTYPE") == "16BIT") bitpix = "16";
  else if (ui.GetString ("BITTYPE") == "32BIT") bitpix = "-32";
  else {
    string msg = "Pixel type of [" + ui.GetString("BITTYPE") + "] is unsupported"; 
    throw iException::Message(iException::User, msg, _FILEINFO_);
  }

  //  Determine bit size and calculate number of bytes to write
  //  for each line.
  if (bitpix == "8") p.SetOutputType(Isis::UnsignedByte);
  if (bitpix == "16") p.SetOutputType(Isis::SignedWord);
  if (bitpix == "-32") p.SetOutputType(Isis::Real);
  
  // determine core base and multiplier, set up the stretch
  PvlGroup pix = icube->Label()->FindObject("IsisCube").FindObject("Core").FindGroup("Pixels");
  double scale = pix["Multiplier"][0].ToDouble();
  double base = pix["Base"][0].ToDouble();

  if (ui.GetString("STRETCH") != "NONE" && bitpix != "-32") {
    if (ui.GetString("STRETCH") == "LINEAR") {
      p.SetInputRange();
    }
    else if (ui.GetString("STRETCH") == "MANUAL") {
       p.SetInputRange(ui.GetDouble("MINIMUM"), ui.GetDouble("MAXIMUM"));
    }
    
    // create a proper scale so pixels look like 32bit data.
    scale = ((p.GetInputMaximum() - p.GetInputMinimum()) *
            (p.GetOutputMaximum() - p.GetOutputMinimum()));

    // round off after 14 decimals to avoid system architecture differences
    scale = ((floor(scale * 1e14)) / 1e14);

    // create a proper zero point so pixels look like 32bit data.
    base = -1.0 * (scale * p.GetOutputMinimum()) + p.GetInputMinimum();
    // round off after 14 decimals to avoid system architecture differences
    base = ((floor(base * 1e14)) / 1e14);
  }

  
  //////////////////////////////////////////
  // Write the minimal fits header	  //
  //////////////////////////////////////////
  string header;
  
  // specify that this file conforms to simple fits standard
  header += FitsKeyword("SIMPLE", true, "T");  
  
  
  // specify the bits per pixel
  header += FitsKeyword("BITPIX", true, bitpix);
  
  // specify the number of data axes (2: samples by lines)
  int axes = 2;
  if (icube->Bands() > 1) {
    axes = 3;
  }
  
  header += FitsKeyword("NAXIS", true, iString(axes));
  
  // specify the limit on data axis 1 (number of samples)
  header += FitsKeyword("NAXIS1", true, iString(icube->Samples()));

  // specify the limit on data axis 2 (number of lines)
  header += FitsKeyword("NAXIS2", true, iString(icube->Lines()));
 
  if (axes == 3){
    header += FitsKeyword("NAXIS3", true, iString(icube->Bands()));
  }

  header += FitsKeyword("BZERO", true,  base);

  header += FitsKeyword("BSCALE", true, scale);
  
  // Sky and All cases  
  if (ui.GetString("INFO") == "SKY" || ui.GetString("INFO") == "ALL") {  
    iString msg = "cube has not been skymapped";
    PvlGroup map;

    if (icube->HasGroup("mapping")) {
      map = icube->GetGroup("mapping");   
      msg = (string)map["targetname"];
    }
//.........这里部分代码省略.........
开发者ID:assutech,项目名称:isis3,代码行数:101,代码来源:isis2fits.cpp

示例8: IsisMain

void IsisMain(){

  const std::string hical_program = "hicalbeta";
  const std::string hical_version = "3.5";
  const std::string hical_revision = "$Revision: 1.14 $";
  const std::string hical_runtime = Application::DateTime();

  UserInterface &ui = Application::GetUserInterface();

  string procStep("prepping phase");
  try {
//  The output from the last processing is the input into subsequent processing
    ProcessByLine p;

    Cube *hifrom = p.SetInputCube("FROM");
    int nsamps = hifrom->Samples();
    int nlines = hifrom->Lines();

//  Initialize the configuration file
    string conf(ui.GetAsString("CONF"));
    HiCalConf hiconf(*(hifrom->Label()), conf);
    DbProfile hiprof = hiconf.getMatrixProfile();

// Check for label propagation and set the output cube
    Cube *ocube = p.SetOutputCube("TO");
    if ( !IsTrueValue(hiprof,"PropagateTables", "TRUE") ) {
      RemoveHiBlobs(*(ocube->Label()));
    }

//  Set specified profile if entered by user
    if (ui.WasEntered("PROFILE")) {
      hiconf.selectProfile(ui.GetAsString("PROFILE"));
    }


//  Add OPATH parameter to profiles
    if (ui.WasEntered("OPATH")) {
      hiconf.add("OPATH",ui.GetAsString("OPATH"));
    }
    else {
      //  Set default to output directory
      hiconf.add("OPATH", Filename(ocube->Filename()).Path());
    }

//  Do I/F output DN conversions
    string units = ui.GetString("UNITS");

    //  Allocate the calibration list
    calVars = new MatrixList;

//  Set up access to HiRISE ancillary data (tables, blobs) here.  Note it they
//  are gone, this will error out. See PropagateTables in conf file.
    HiCalData caldata(*hifrom);

////////////////////////////////////////////////////////////////////////////
//  FixGaps (Z_f) Get buffer pixels and compute coefficients for equation
//     y = a[0] + a[1]*x + a[2] * exp(a[3] * x)
//        where y is the average of the buffer pixel region,
//          and x is the time at each line in electrons/sec/pixel
    procStep = "Zf module";
    hiconf.selectProfile("Zf");
    hiprof = hiconf.getMatrixProfile();
    HiHistory ZfHist;
    ZfHist.add("Profile["+ hiprof.Name()+"]");
    if ( !SkipModule(hiprof) ) {
      DriftBuffer driftB(caldata, hiconf);
      calVars->add("Zf", driftB.ref());
      ZfHist = driftB.History();
      if ( hiprof.exists("DumpModuleFile") ) {
        driftB.Dump(hiconf.getMatrixSource("DumpModuleFile",hiprof));
      }
    }
    else {
      //  NOT RECOMMENDED!  This is required for the next step!
      //  SURELY must be skipped with Z_d step as well!
      calVars->add("Zf", HiVector(nlines, 0.0));
      ZfHist.add("Debug::SkipModule invoked!");
    }

/////////////////////////////////////////////////////////////////////
// DriftCorrect (Z_d)
//  Now compute the equation of fit
// 
    procStep = "Zd module";
    HiHistory ZdHist;
    hiconf.selectProfile("Zd");
    hiprof = hiconf.getMatrixProfile();
    ZdHist.add("Profile["+ hiprof.Name()+"]");
    if (!SkipModule(hiconf.getMatrixProfile("Zd")) ) { 
      DriftCorrect driftC(hiconf);
      calVars->add("Zd", driftC.Normalize(driftC.Solve(calVars->get("Zf"))));
      ZdHist = driftC.History();
      if ( hiprof.exists("DumpModuleFile") ) {
        driftC.Dump(hiconf.getMatrixSource("DumpModuleFile",hiprof));
      }
    }
    else {
      calVars->add("Zd", HiVector(nlines, 0.0));
      ZdHist.add("Debug::SkipModule invoked!");
    }
//.........这里部分代码省略.........
开发者ID:assutech,项目名称:isis3,代码行数:101,代码来源:hicalbeta.cpp

示例9: IsisMain

void IsisMain() {

  // Get the list of cubes to process
  FileList imageList;
  UserInterface &ui = Application::GetUserInterface();
  imageList.Read(ui.GetFilename("FROMLIST"));

  // Read to list if one was entered
  FileList outList;
  if (ui.WasEntered("TOLIST")) {
    outList.Read(ui.GetFilename("TOLIST"));
  }

  // Check for user input errors and return the file list sorted by CCD numbers
  ErrorCheck(imageList, outList);  

  // Adds statistics for whole and side regions of every cube
  for (int img=0; img<(int)imageList.size(); img++) {
    g_s.Reset();
    g_sl.Reset();
    g_sr.Reset();

    iString maxCube ((int)imageList.size());
    iString curCube (img+1);
    ProcessByLine p;
    p.Progress()->SetText("Gathering Statistics for Cube " + 
                          curCube + " of " + maxCube);
    CubeAttributeInput att;
    const std::string inp = imageList[img];
    p.SetInputCube(inp, att);
    p.StartProcess(GatherStatistics);
    p.EndProcess();

    g_allStats.push_back(g_s);
    g_leftStats.push_back(g_sl);
    g_rightStats.push_back(g_sr);
  }
  
  // Initialize the object that will calculate the gains and offsets
  g_oNorm = new OverlapNormalization(g_allStats);
  
  // Add the known overlaps between two cubes, and apply a weight to each
  // overlap equal the number of pixels in the overlapping area
  for (int i=0; i<(int)imageList.size()-1; i++) {
    int j = i+1;
    g_oNorm->AddOverlap(g_rightStats[i], i, g_leftStats[j], j, 
                           g_rightStats[i].ValidPixels());
  }

  // Read in and then set the holdlist
  FileList holdList;
  holdList.Read(ui.GetFilename("HOLD"));

  for (unsigned i=0; i<holdList.size(); i++) {
    int index = -1;
    for (unsigned j=0; j<imageList.size(); j++) {
      std::string curName = imageList.at(j);
      if (curName.compare(holdList[i]) == 0) {
        index = j;
        g_oNorm->AddHold(index);
      }
    }
  }

  // Attempt to solve the least squares equation
  g_oNorm->Solve(OverlapNormalization::Both);

  // Apply correction to the cubes if desired
  bool applyopt = ui.GetBoolean("APPLY");
  if (applyopt) {
    // Loop through correcting the gains and offsets by line for every cube
    for (int img=0; img<(int)imageList.size(); img++) {
      g_imageNum = img;
      ProcessByLine p;
      iString max_cube ((int)imageList.size());
      iString cur_cube (img+1);
      p.Progress()->SetText("Equalizing Cube " + cur_cube + " of " + max_cube);
      CubeAttributeInput att;
      const std::string inp = imageList[img];
      Cube *icube = p.SetInputCube(inp, att);
      Filename file = imageList[img];

      // Establish the output file depending upon whether or not a to list
      // was entered
      std::string out;
      if (ui.WasEntered("TOLIST")) {
	out = outList[img];
      }
      else {
	Filename file = imageList[img];
	out = file.Path() + "/" + file.Basename() + ".equ." + file.Extension();
      }

      CubeAttributeOutput outAtt;
      p.SetOutputCube(out,outAtt,icube->Samples(),icube->Lines(),icube->Bands());
      p.StartProcess(Apply);
      p.EndProcess();
    }    
  }

//.........这里部分代码省略.........
开发者ID:assutech,项目名称:isis3,代码行数:101,代码来源:hiequal.cpp

示例10: IsisMain

void IsisMain() {
  Process p;

  // Get the list of names of input CCD cubes to stitch together
  FileList flist;
  UserInterface &ui = Application::GetUserInterface();
  flist.Read(ui.GetFilename("FROMLIST"));
  if (flist.size() < 1) {
    string msg = "The list file[" + ui.GetFilename("FROMLIST") +
    " does not contain any filenames";
    throw iException::Message(iException::User,msg,_FILEINFO_);
  }

  string projection("Equirectangular");
  if(ui.WasEntered("MAP")) {
      Pvl mapfile(ui.GetFilename("MAP"));
      projection = (string) mapfile.FindGroup("Mapping")["ProjectionName"];
  }

  if(ui.WasEntered("PROJECTION")) {
      projection = ui.GetString("PROJECTION");
  }

  // Gather other user inputs to projection
  string lattype = ui.GetString("LATTYPE");
  string londir  = ui.GetString("LONDIR");
  string londom  = ui.GetString("LONDOM");
  int digits = ui.GetInteger("PRECISION");

  // Fix them for mapping group
  lattype = (lattype == "PLANETOCENTRIC") ? "Planetocentric" : "Planetographic";
  londir = (londir == "POSITIVEEAST") ? "PositiveEast" : "PositiveWest";

  Progress prog;
  prog.SetMaximumSteps(flist.size());
  prog.CheckStatus();

  Statistics scaleStat;
  Statistics longitudeStat;
  Statistics latitudeStat;
  Statistics equiRadStat;
  Statistics poleRadStat;
  PvlObject fileset("FileSet");

  // Save major equitorial and polar radii for last occuring
  double eqRad; 
  double eq2Rad; 
  double poleRad;

  string target("Unknown");
  for (unsigned int i = 0 ; i < flist.size() ; i++) {
    // Set the input image, get the camera model, and a basic mapping
    // group
    Cube cube;
    cube.Open(flist[i]);

    int lines = cube.Lines();
    int samples = cube.Samples();


    PvlObject fmap("File");
    fmap += PvlKeyword("Name",flist[i]);
    fmap += PvlKeyword("Lines", lines);
    fmap += PvlKeyword("Samples", samples);

    Camera *cam = cube.Camera();
    Pvl mapping;
    cam->BasicMapping(mapping);
    PvlGroup &mapgrp = mapping.FindGroup("Mapping");
    mapgrp.AddKeyword(PvlKeyword("ProjectionName",projection),Pvl::Replace);    
    mapgrp.AddKeyword(PvlKeyword("LatitudeType",lattype),Pvl::Replace);    
    mapgrp.AddKeyword(PvlKeyword("LongitudeDirection",londir),Pvl::Replace);    
    mapgrp.AddKeyword(PvlKeyword("LongitudeDomain",londom),Pvl::Replace);    

    // Get the radii
    double radii[3];
    cam->Radii(radii);

    eqRad   = radii[0] * 1000.0;
    eq2Rad  = radii[1] * 1000.0;
    poleRad = radii[2] * 1000.0;

    target = cam->Target();
    equiRadStat.AddData(&eqRad, 1);
    poleRadStat.AddData(&poleRad, 1);

    // Get resolution
    double lowres = cam->LowestImageResolution();
    double hires = cam->HighestImageResolution();
    scaleStat.AddData(&lowres, 1);
    scaleStat.AddData(&hires, 1);

    double pixres = (lowres+hires)/2.0;
    double scale = Scale(pixres, poleRad, eqRad);
    mapgrp.AddKeyword(PvlKeyword("PixelResolution",pixres),Pvl::Replace);
    mapgrp.AddKeyword(PvlKeyword("Scale",scale,"pixels/degree"),Pvl::Replace);
    mapgrp += PvlKeyword("MinPixelResolution",lowres,"meters");
    mapgrp += PvlKeyword("MaxPixelResolution",hires,"meters");

    // Get the universal ground range
//.........这里部分代码省略.........
开发者ID:assutech,项目名称:isis3,代码行数:101,代码来源:mosrange.cpp

示例11: IsisMain

void IsisMain(){

  UserInterface &ui = Application::GetUserInterface();

  ProcessByLine proc;
  Cube *cube = proc.SetInputCube("FROM");
  BigInt npixels(cube->Lines() * cube->Samples());
  
//  Initialize the cleaner routine
  try {
    delete iclean;
    iclean = new HiImageClean(*cube);
  } 
  catch (iException &ie) {
    std::string message = "Error attempting to initialize HiRISE cleaner object";
    throw (iException::Message(iException::Programmer,message,_FILEINFO_));
  }
  catch (...) {
    std::string message = "Unknown error occured attempting to initialize "
                          "HiRISE cleaner object";
    throw (iException::Message(iException::Programmer,message,_FILEINFO_));
  }

//  For IR10, channel 1 lets restrict the last 3100 lines of dark current
  PvlGroup &instrument = cube->GetGroup("Instrument");
  std::string ccd = (std::string) instrument["CcdId"];
  int channel = instrument["ChannelNumber"];
  if ((ccd == "IR10") && (channel  == 1)) {
    int bin = instrument["Summing"];
    int lastLine = cube->Lines() - ((3100/bin) + iclean->getFilterWidth()/2);
    if (lastLine > 1) { iclean->setLastGoodLine(lastLine); }
  }

#if defined(DEBUG)
  std::cout << "Lines: " << cube->Lines() << "   GoodLines: " 
            << iclean->getLastGoodLine() << std::endl;    
#endif

//  Get the output file reference for label update
  Cube *ocube = proc.SetOutputCube("TO");
  proc.StartProcess(cleanImage);
  iclean->propagateBlobs(ocube);
  proc.EndProcess();

//  Write statistics to file if requested
  if (ui.WasEntered("CLEANSTATS")) {
    std::string darkfile = ui.GetFilename("CLEANSTATS");
    std::ofstream dfile;
    dfile.open(darkfile.c_str(), std::ios::out | std::ios::trunc);
    dfile << *iclean;
    dfile.close();
  }

//  Dump stats to standard out
  Pvl p;
  PvlGroup grp;
  iclean->PvlImageStats(grp);
  p.AddGroup(grp);
  Application::Log(grp);
  BigInt nNulled = iclean->TotalNulled();

  delete iclean;
  iclean = 0;

// Check for calibration problems
  if (nNulled != 0) {
    double tpixels((double) nNulled / (double) npixels);
    std::ostringstream mess;
    mess << "There were " << nNulled << " of " << npixels << " ("
         << std::setw(6) << std::setprecision(2) << (tpixels * 100.0)
         << "%) due to insufficient calibration data (LUTTED or Gaps)" 
         << std::ends;
    throw (iException::Message(iException::Math,mess.str(),_FILEINFO_));
  }
}
开发者ID:assutech,项目名称:isis3,代码行数:75,代码来源:hiclean.cpp

示例12: IsisMain

/**
 * This is the main method. Makeflat runs in three steps:
 *
 * 1) Calculate statistics
 *   - For all cameras, this checks for one band and matching
 *       sample counts.
 *   - For framing cameras, this checks the standard deviation of
 *       the images and records the averages of each image
 *   - For push frame cameras, this calls CheckFramelets for each
 *       image.
 *
 * 2) Create the temporary file, collect more detailed statistics
 *   - For all cameras, this generates the temporary file and calculates
 *       the final exclusion list
 *   - For framing/push frame cameras, the temporary file is
 *       2 bands, where the first is a sum of DNs from each image/framelet
 *       and the second band is a count of valid DNs that went into each sum
 *
 *  3) Create the final flat field file
 *   - For all cameras, this processes the temporary file to create the final flat
 *       field file.
 */
void IsisMain() {
    // Initialize variables
    ResetGlobals();

    UserInterface &ui = Application::GetUserInterface();
    maxStdev = ui.GetDouble("STDEVTOL");

    if(ui.GetString("IMAGETYPE") == "FRAMING") {
        cameraType = Framing;

        // framing cameras need to figure this out automatically
        //   during step 1
        numFrameLines = -1;
    }
    else if(ui.GetString("IMAGETYPE") == "LINESCAN") {
        cameraType = LineScan;
        numFrameLines = ui.GetInteger("NUMLINES");
    }
    else {
        cameraType = PushFrame;
        numFrameLines = ui.GetInteger("FRAMELETHEIGHT");
    }

    FileList inList(ui.GetFilename("FROMLIST"));
    Progress progress;

    tempFileLength = 0;
    numOutputSamples = 0;

    /**
     * Line scan progress is based on the input list, whereas
     * the other cameras take much longer and are based on the
     * images themselves. Prepare the progress if we're doing
     * line scan.
     */
    if(cameraType == LineScan) {
        progress.SetText("Calculating Number of Image Lines");
        progress.SetMaximumSteps(inList.size());
        progress.CheckStatus();
    }

    /**
     *  For a push frame camera, the temp file is one framelet.
     *   Technically this is the same for the framing, but we
     *   don't know the height of a framelet yet.
     */
    if(cameraType == PushFrame) {
        tempFileLength = numFrameLines;
    }

    /**
     * Start pass 1, use global currImage so that methods called
     *   know the image we're processing.
     */
    for(currImage = 0; currImage < inList.size(); currImage++) {
        /**
         * Read the current cube into memory
         */
        Cube tmp;
        tmp.Open(Filename(inList[currImage]).Expanded());

        /**
         * If we haven't determined how many samples the output
         *   should have, we can do so now
         */
        if(numOutputSamples == 0 && tmp.Bands() == 1) {
            numOutputSamples = tmp.Samples();
        }

        /**
         * Try and validate the image, quick tests first!
         *
         * (imageValid &= means imageValid = imageValid && ...)
         */
        bool imageValid = true;

        // Only single band images are acceptable
        imageValid &= (tmp.Bands() == 1);
//.........这里部分代码省略.........
开发者ID:novas0x2a,项目名称:isis3,代码行数:101,代码来源:makeflat.cpp

示例13: IsisMain

void IsisMain() {
  //Create a process to create the input cubes
  Process p;
  //Create the input cubes, matching sample/lines
  Cube *inCube = p.SetInputCube ("FROM");
  Cube *latCube = p.SetInputCube("LATCUB", SpatialMatch);
  Cube *lonCube = p.SetInputCube("LONCUB", SpatialMatch);

  //A 1x1 brick to read in the latitude and longitude DN values from
  //the specified cubes
  Brick latBrick(1,1,1, latCube->PixelType());
  Brick lonBrick(1,1,1, lonCube->PixelType());

  UserInterface &ui = Application::GetUserInterface();

  //Set the sample and line increments
  int sinc = (int)(inCube->Samples() * 0.10);
  if(ui.WasEntered("SINC")) {
    sinc = ui.GetInteger("SINC");
  }

  int linc = (int)(inCube->Lines() * 0.10);
  if(ui.WasEntered("LINC")) {
    linc = ui.GetInteger("LINC");
  }

  //Set the degree of the polynomial to use in our functions
  int degree = ui.GetInteger("DEGREE");

  //We are using a polynomial with two variables
  PolynomialBivariate sampFunct(degree); 
  PolynomialBivariate lineFunct(degree);

  //We will be solving the function using the least squares method
  LeastSquares sampSol(sampFunct);
  LeastSquares lineSol(lineFunct);

  //Setup the variables for solving the stereographic projection
  //x = cos(latitude) * sin(longitude - lon_center)
  //y = cos(lat_center) * sin(latitude) - sin(lat_center) * cos(latitude) * cos(longitude - lon_center)

  //Get the center lat and long from the input cubes
  double lat_center = latCube->Statistics()->Average() * PI/180.0;
  double lon_center = lonCube->Statistics()->Average() * PI/180.0;


  /**
   * Loop through lines and samples projecting the latitude and longitude at those
   * points to stereographic x and y and adding these points to the LeastSquares 
   * matrix. 
   */
  for(int i = 1; i <= inCube->Lines(); i+= linc) {
    for(int j = 1; j <= inCube->Samples(); j+= sinc) {
      latBrick.SetBasePosition(j, i, 1);
      latCube->Read(latBrick);
      if(IsSpecial(latBrick.at(0))) continue;
      double lat = latBrick.at(0) * PI/180.0;
      lonBrick.SetBasePosition(j, i, 1);
      lonCube->Read(lonBrick);
      if(IsSpecial(lonBrick.at(0))) continue;
      double lon = lonBrick.at(0) * PI/180.0;

      //Project lat and lon to x and y using a stereographic projection
      double k = 2/(1 + sin(lat_center) * sin(lat) + cos(lat_center)*cos(lat)*cos(lon - lon_center));
      double x = k * cos(lat) * sin(lon - lon_center);
      double y = k * (cos(lat_center) * sin(lat)) - (sin(lat_center) * cos(lat) * cos(lon - lon_center));

      //Add x and y to the least squares matrix
      vector<double> data;
      data.push_back(x);
      data.push_back(y);
      sampSol.AddKnown(data, j);
      lineSol.AddKnown(data, i);

      //If the sample increment goes past the last sample in the line, we want to
      //always read the last sample..
      if(j != inCube->Samples() && j + sinc > inCube->Samples()) {
        j = inCube->Samples() - sinc;
      }
    }
    //If the line increment goes past the last line in the cube, we want to
    //always read the last line..
    if(i != inCube->Lines() && i + linc > inCube->Lines()) {    
      i = inCube->Lines() - linc;
    }
  }

  //Solve the least squares functions using QR Decomposition
  sampSol.Solve(LeastSquares::QRD);
  lineSol.Solve(LeastSquares::QRD);

  //If the user wants to save the residuals to a file, create a file and write
  //the column titles to it.
  TextFile oFile;
  if(ui.WasEntered("RESIDUALS")) {
    oFile.Open(ui.GetFilename("RESIDUALS"), "overwrite");
    oFile.PutLine("Sample,\tLine,\tX,\tY,\tSample Error,\tLine Error\n");
  }

  //Gather the statistics for the residuals from the least squares solutions
//.........这里部分代码省略.........
开发者ID:assutech,项目名称:isis3,代码行数:101,代码来源:nocam2map.cpp

示例14: IsisMain


//.........这里部分代码省略.........

      for(int index = 0; index < latitudes.Keywords(); index ++) {
        if(!userMappingGrp.HasKeyword(latitudes[index].Name())) {
          if(((string)userMappingGrp["LatitudeType"]).compare("Planetographic") == 0) {
            outMappingGrp[latitudes[index].Name()] = Projection::ToPlanetographic(
                                                      (double)fromMappingGrp[latitudes[index].Name()],
                                                      (double)fromMappingGrp["EquatorialRadius"],
                                                      (double)fromMappingGrp["PolarRadius"]);
          }
          else {
            outMappingGrp[latitudes[index].Name()] = Projection::ToPlanetocentric(
                                                      (double)fromMappingGrp[latitudes[index].Name()],
                                                      (double)fromMappingGrp["EquatorialRadius"],
                                                      (double)fromMappingGrp["PolarRadius"]);
          }
        }
      }

    }
  }

  // If MinLon/MaxLon out of order, we weren't able to calculate the correct values
  if((double)outMappingGrp["MinimumLongitude"] >= (double)outMappingGrp["MaximumLongitude"]) {
    if(!ui.WasEntered("MINLON") || !ui.WasEntered("MAXLON")) {
      string msg = "Unable to determine the correct [MinimumLongitude,MaximumLongitude].";
      msg += " Please specify these values in the [MINLON,MAXLON] parameters";
      throw iException::Message(iException::Pvl,msg,_FILEINFO_);
    }
  }

  int samples,lines;
  Pvl mapData;
  // Copy to preserve cube labels so we can match cube size
  if (userPvl.HasObject("IsisCube")) {
    mapData = userPvl;
    mapData.FindObject("IsisCube").DeleteGroup("Mapping");
    mapData.FindObject("IsisCube").AddGroup(outMappingGrp);
  }
  else {
    mapData.AddGroup(outMappingGrp);
  }

  // *NOTE: The UpperLeftX,UpperLeftY keywords will not be used in the CreateForCube
  //   method, and they will instead be recalculated. This is correct.
  Projection *outproj = ProjectionFactory::CreateForCube(mapData,samples,lines,
                                                         ui.GetBoolean("MATCHMAP"));

  // Set up the transform object which will simply map
  // output line/samps -> output lat/lons -> input line/samps
  Transform *transform = new map2map (icube->Samples(),
                                       icube->Lines(),
                                       icube->Projection(),
                                       samples,
                                       lines,
                                       outproj,
                                       ui.GetBoolean("TRIM"));

  // Allocate the output cube and add the mapping labels
  Cube *ocube = p.SetOutputCube ("TO", transform->OutputSamples(),
                                            transform->OutputLines(),
                                            icube->Bands());

  PvlGroup cleanOutGrp = outproj->Mapping();

  // ProjectionFactory::CreateForCube updated mapData to have the correct
  //   upperleftcornerx, upperleftcornery, scale and resolution. Use these
  //   updated numbers.
  cleanOutGrp.AddKeyword(mapData.FindGroup("Mapping",Pvl::Traverse)["UpperLeftCornerX"], Pvl::Replace);
  cleanOutGrp.AddKeyword(mapData.FindGroup("Mapping",Pvl::Traverse)["UpperLeftCornerY"], Pvl::Replace);
  cleanOutGrp.AddKeyword(mapData.FindGroup("Mapping",Pvl::Traverse)["Scale"], Pvl::Replace);
  cleanOutGrp.AddKeyword(mapData.FindGroup("Mapping",Pvl::Traverse)["PixelResolution"], Pvl::Replace);

  ocube->PutGroup(cleanOutGrp);

  // Set up the interpolator
  Interpolator *interp;
  if (ui.GetString("INTERP") == "NEARESTNEIGHBOR") {
    interp = new Interpolator(Interpolator::NearestNeighborType);
  }
  else if (ui.GetString("INTERP") == "BILINEAR") {
    interp = new Interpolator(Interpolator::BiLinearType);
  }
  else if (ui.GetString("INTERP") == "CUBICCONVOLUTION") {
    interp = new Interpolator(Interpolator::CubicConvolutionType);
  }
  else {
    string msg = "Unknow value for INTERP [" + ui.GetString("INTERP") + "]";
    throw iException::Message(iException::Programmer,msg,_FILEINFO_);
  }

  // Warp the cube
  p.StartProcess(*transform, *interp);
  p.EndProcess();

  Application::Log(cleanOutGrp);

  // Cleanup
  delete transform;
  delete interp;
}
开发者ID:assutech,项目名称:isis3,代码行数:101,代码来源:map2map.cpp

示例15: IsisMain

void IsisMain() {
  UserInterface &ui = Application::GetUserInterface();
  /*Processing steps
  1.  Open and read the jitter table, convert the pixel offsets to angles,
      and create the polynomials (solve for the coefficients) to use to do
      the high pass filter putting the results into a rotation matrix in the jitter class.
  2.  Apply the jitter correction in the LineScanCameraRotation object of the master cube.
  3.  Loop through FROMLIST correcting the pointing and writing out the
      updated camera pointing from the master cube
      */

  int degree = ui.GetInteger("DEGREE");

  // Get the input file list to make sure it is not empty and the master cube is included
  FileList list;
  list.Read(ui.GetFilename("FROMLIST"));

  if (list.size() < 1) {
    string msg = "The input list file [" + ui.GetFilename("FROMLIST") + "is empty";
    throw iException::Message(iException::User,msg,_FILEINFO_);
  }

  int ifile = 0;
  // Make sure the master file is included in the input file list
  while (ifile < (int) list.size() && Filename(list[ifile]).Expanded() != Filename(ui.GetFilename("MASTER")).Expanded()) {
    ifile++;
  }

  if (ifile >= (int) list.size()) {
    string msg = "The master file, [" + Filename(ui.GetFilename("MASTER")).Expanded() + " is not included in " + 
      "the input list file " + ui.GetFilename("FROMLIST") + "]";
    throw iException::Message(iException::User,msg,_FILEINFO_);
  }

  bool step2 = false;
  PvlGroup gp("AppjitResults");

  //Step 1:  Create the jitter rotation

  try {
    // Open the master cube
    Cube cube;
    cube.Open(ui.GetFilename("MASTER"),"rw");
    
    //check for existing polygon, if exists delete it
    if (cube.Label()->HasObject("Polygon")){
      cube.Label()->DeleteObject("Polygon");
    }

    // Get the camera
    Camera *cam = cube.Camera();
    if (cam->DetectorMap()->LineRate() == 0.0) {
      string msg = "[" + ui.GetFilename("MASTER") + "] is not a line scan camera image";
      throw iException::Message(Isis::iException::User,msg,_FILEINFO_);
    }

    // Create the master rotation to be corrected 
    int frameCode = cam->InstrumentRotation()->Frame();
    cam->SetImage(int(cube.Samples()/2), int(cube.Lines()/2) );
    double tol = cam->PixelResolution();

    if (tol < 0.) {
      // Alternative calculation of .01*ground resolution of a pixel
      tol = cam->PixelPitch()*cam->SpacecraftAltitude()*1000./cam->FocalLength()/100.;
    }
    LineScanCameraRotation crot(frameCode, *(cube.Label()), cam->InstrumentRotation()->GetFullCacheTime(), tol );
    crot.SetPolynomialDegree(ui.GetInteger("DEGREE"));
    crot.SetAxes(1, 2, 3);
    if (ui.WasEntered("PITCHRATE")) crot.ResetPitchRate(ui.GetDouble("PITCHRATE"));
    if (ui.WasEntered("YAW")) crot.ResetYaw(ui.GetDouble("YAW"));
    crot.SetPolynomial();
    double baseTime = crot.GetBaseTime();
    double timeScale = crot.GetTimeScale();
    double fl = cam->FocalLength();
    double pixpitch = cam->PixelPitch();
    std::vector<double> cacheTime = cam->InstrumentRotation()->GetFullCacheTime();

    // Get the jitter in pixels, compute jitter angles, and fit a polynomial to each angle
    PixelOffset jitter(ui.GetFilename("JITTERFILE"), fl, pixpitch, baseTime, timeScale, degree);
    jitter.LoadAngles(cacheTime);
    jitter.SetPolynomial();

    // Set the jitter and apply to the instrument rotation
    crot.SetJitter( &jitter );
    crot.ReloadCache();

    // Pull out the pointing cache as a table and write it
    Table cmatrix = crot.Cache("InstrumentPointing");
    cmatrix.Label().AddComment("Corrected using appjit and" + ui.GetFilename("JITTERFILE"));
    cube.Write(cmatrix);

    // Write out the instrument position table
    Isis::PvlGroup kernels = cube.Label()->FindGroup("Kernels",Isis::Pvl::Traverse);

    // Write out the "Table" label to the tabled kernels in the kernels group
    kernels["InstrumentPointing"] = "Table";
//    kernels["InstrumentPosition"] = "Table";
    cube.PutGroup(kernels);
    cube.Close();
    gp += PvlKeyword("StatusMaster",ui.GetFilename("MASTER") + ":  camera pointing updated");
//.........这里部分代码省略.........
开发者ID:assutech,项目名称:isis3,代码行数:101,代码来源:appjit.cpp


注:本文中的Cube::Samples方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。