本文整理汇总了C++中Cube::bandCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Cube::bandCount方法的具体用法?C++ Cube::bandCount怎么用?C++ Cube::bandCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cube
的用法示例。
在下文中一共展示了Cube::bandCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsisMain
void IsisMain() {
// We will be processing by line first
ProcessByTile lProc;
lProc.Progress()->SetText("First pass");
// Setup the input and output cubes
Cube *magCube = lProc.SetInputCube("MAGNITUDE");
Cube *phaseCube = lProc.SetInputCube("PHASE");
AlphaCube acube(*magCube);
int initSamples = acube.BetaSamples();
int initLines = acube.BetaLines();
int numSamples = magCube->sampleCount();
int numLines = magCube->lineCount();
int numBands = magCube->bandCount();
// error checking for valid input cubes
// i.e. the dimensions of the magnitude and phase cubes
// are the same and are powers of two
if(!fft.IsPowerOfTwo(numSamples) || !fft.IsPowerOfTwo(numLines)
|| magCube->sampleCount() != phaseCube->sampleCount()
|| magCube->lineCount() != phaseCube->lineCount()) {
cerr << "Invalid Cubes: the dimensions of both cubes must be equal"
" powers of 2." << endl;
return;
}
lProc.SetTileSize(numSamples, 1);
Isis::CubeAttributeOutput cao;
lProc.SetOutputCube(tmpMagFileName, cao, numSamples, numLines, numBands);
lProc.SetOutputCube(tmpPhaseFileName, cao, numSamples, numLines, numBands);
// Start the line processing
lProc.ProcessCubes(&IFFT2);
lProc.Finalize();
// Then process by sample
ProcessByTile sProc;
sProc.Progress()->SetText("Second pass");
sProc.SetTileSize(1, numLines);
// Setup the input and output cubes
Isis::CubeAttributeInput cai;
sProc.SetInputCube(tmpMagFileName, cai);
sProc.SetInputCube(tmpPhaseFileName, cai);
// the final output cube is cropped back to the original size
sProc.SetOutputCube("TO", initSamples, initLines, numBands);
//Start the sample proccessing
sProc.ProcessCubes(&IFFT1);
sProc.Finalize();
remove(tmpMagFileName.toAscii().data());
remove(tmpPhaseFileName.toAscii().data());
}
示例2: IsisMain
void IsisMain() {
// Create a process by line object
ProcessByLine p;
// Get the size of the cube
Cube *icube = p.SetInputCube("FROM");
// Open output text file
UserInterface &ui = Application::GetUserInterface();
QString to = ui.GetFileName("TO", "txt");
fout.open(to.toAscii().data());
// Print header if needed
if(ui.GetBoolean("HEADER")) {
fout << "Input Cube: " << icube->fileName() << endl;
fout << "Samples:Lines:Bands: " << icube->sampleCount() << ":" <<
icube->lineCount() << ":" << icube->bandCount() << endl;
}
// List the cube
p.StartProcess(isis2ascii);
p.EndProcess();
fout.close();
}
示例3: init
/**
* @brief Initialize class from input PVL and Cube files
*
* This method is typically called at class instantiation time,
* but is reentrant. It reads the parameter PVL file and
* extracts Photometric model and Normalization models from it.
* The cube is needed to match all potential profiles for each
* band.
*
* @param pvl Input PVL parameter files
* @param cube Input cube file to correct
*
* @author Kris Becker - 2/22/2010
* @history 2010-02-25 Kris Becker Added check for valid incidence angle
*/
void Hillier::init(PvlObject &pvl, Cube &cube) {
// Make it reentrant
_profiles.clear();
_bandpho.clear();
// Interate over all Photometric groups
_normProf = DbProfile(pvl.findObject("NormalizationModel").findGroup("Algorithm", Pvl::Traverse));
_iRef = toDouble(ConfKey(_normProf, "IncRef", toString(30.0)));
_eRef = toDouble(ConfKey(_normProf, "EmaRef", toString(0.0)));
_gRef = toDouble(ConfKey(_normProf, "PhaRef", toString(_iRef)));
// Check for valid incidence angle
if(_iRef > fabs(90.0)) {
ostringstream mess;
mess << "Invalid incidence angle (" << _iRef
<< " >= 90.0) provided in PVL config file " << pvl.fileName();
throw IException(IException::User, mess.str(), _FILEINFO_);
}
PvlObject &phoObj = pvl.findObject("PhotometricModel");
DbProfile phoProf = DbProfile(phoObj);
PvlObject::PvlGroupIterator algo = phoObj.beginGroup();
while(algo != phoObj.endGroup()) {
if(algo->name().toLower() == "algorithm") {
_profiles.push_back(DbProfile(phoProf, DbProfile(*algo)));
}
++algo;
}
Pvl *label = cube.label();
PvlKeyword center = label->findGroup("BandBin", Pvl::Traverse)["Center"];
QString errs("");
for(int i = 0; i < cube.bandCount() ; i++) {
Parameters parms = findParameters(toDouble(center[i]));
if(parms.IsValid()) {
parms.band = i + 1;
_camera->SetBand(i + 1);
parms.phoStd = photometry(parms, _iRef, _eRef, _gRef);
_bandpho.push_back(parms);
}
else { // Appropriate photometric parameters not found
ostringstream mess;
mess << "Band " << i + 1 << " with wavelength Center = " << center[i]
<< " does not have PhotometricModel Algorithm group/profile";
IException e(IException::User, mess.str(), _FILEINFO_);
errs += e.toString() + "\n";
}
}
// Check for errors and throw them all at the same time
if(!errs.isEmpty()) {
errs += " --> Errors in the input PVL file \"" + pvl.fileName() + "\"";
throw IException(IException::User, errs, _FILEINFO_);
}
return;
}
示例4: IsisMain
void IsisMain() {
ProcessByBrick p;
Cube *icube = p.SetInputCube("FROM");
int numDimensions = icube->bandCount();
p.SetBrickSize(128, 128, numDimensions);
// The output cube with no attributes and real pixel type
Isis::CubeAttributeOutput cao;
cao.setPixelType(Isis::Real);
p.SetOutputCube(tmpFileName, cao, icube->sampleCount(), icube->lineCount(), icube->bandCount());
// Get the data for the transform matrix
pca = Isis::PrincipalComponentAnalysis(numDimensions);
ProcessByBrick p2;
p2.SetBrickSize(128, 128, numDimensions);
p2.SetInputCube("FROM");
p2.Progress()->SetText("Computing Transform");
p2.StartProcess(GetData);
p2.EndProcess();
pca.ComputeTransform();
p.Progress()->SetText("Transforming Cube");
p.StartProcess(Transform);
p.EndProcess();
Isis::CubeAttributeInput cai;
Cube *icube2 = p.SetInputCube(tmpFileName, cai);
for(int i = 0; i < numDimensions; i++) {
stretches.push_back(new GaussianStretch(*(icube2->histogram(i + 1))));
}
p.SetOutputCube("TO");
p.SetBrickSize(128, 128, numDimensions);
p.Progress()->SetText("Stretching Cube");
p.StartProcess(NormalizeAndInvert);
for(int i = 0; i < numDimensions; i++) delete stretches[i];
stretches.clear();
p.EndProcess();
remove(tmpFileName.toAscii().data());
}
示例5: IsisMain
void IsisMain() {
ProcessByLine p;
Cube *icube = p.SetInputCube("FROM");
p.SetOutputCube("TO");
double gsigma = Isis::Application::GetUserInterface().GetDouble("GSIGMA");
for(int i = 0; i < icube->bandCount(); i++) {
Histogram hist = *(icube->histogram(i + 1));
double mean = (hist.Maximum() + hist.Minimum()) / 2.0;
double stdev = (hist.Maximum() - hist.Minimum()) / (2.0 * gsigma);
stretch.push_back(new GaussianStretch(hist, mean, stdev));
}
p.StartProcess(gauss);
for(int i = 0; i < icube->bandCount(); i++) delete stretch[i];
stretch.clear();
p.EndProcess();
}
示例6: IException
/**
* Set the output cube to specified file name and specified input images
* and output attributes and lat,lons
*/
Isis::Cube *ProcessMapMosaic::SetOutputCube(const QString &inputFile, PvlGroup mapping,
CubeAttributeOutput &oAtt, const QString &mosaicFile) {
if (OutputCubes.size() != 0) {
QString msg = "You can only specify one output cube and projection";
throw IException(IException::Programmer, msg, _FILEINFO_);
}
if (mapping.hasKeyword("UpperLeftCornerX"))
mapping.deleteKeyword("UpperLeftCornerX");
if (mapping.hasKeyword("UpperLeftCornerY"))
mapping.deleteKeyword("UpperLeftCornerY");
if (p_createMosaic) {
Pvl newMap;
newMap.addGroup(mapping);
int samps, lines, bands;
delete ProjectionFactory::CreateForCube(newMap, samps, lines, false);
// Initialize the mosaic
ProcessByLine p;
CubeAttributeInput inAtt(inputFile);
Cube *propCube = p.SetInputCube(inputFile, inAtt);
bands = propCube->bandCount();
// If track set, create the origin band
if (GetTrackFlag()) {
bands += 1;
}
// For average priority, get the new band count
else if (GetImageOverlay() == AverageImageWithMosaic) {
bands *= 2;
}
p.PropagateHistory(false);
p.PropagateLabels(false);
Cube *ocube = p.SetOutputCube(mosaicFile, oAtt, samps, lines, bands);
p.Progress()->SetText("Initializing mosaic");
p.ClearInputCubes();
p.StartProcess(ProcessMapMosaic::FillNull);
// CreateForCube created some keywords in the mapping group that needs to be added
ocube->putGroup(newMap.findGroup("Mapping", Pvl::Traverse));
p.EndProcess();
}
Cube *mosaicCube = new Cube();
AddOutputCube(mosaicCube);
mosaicCube->open(mosaicFile, "rw");
mosaicCube->addCachingAlgorithm(new UniqueIOCachingAlgorithm(2));
return mosaicCube;
}
示例7: CopyCubeIntoBuffer
void CopyCubeIntoBuffer ( QString &fileString, Buffer* &data) {
Cube cube;
FileName filename(fileString);
if (filename.isVersioned())
filename = filename.highestVersion();
if (!filename.fileExists()) {
QString msg = fileString + " does not exist.";
throw IException(IException::User, msg, _FILEINFO_);
}
cube.open(filename.expanded());
Brick brick(cube.sampleCount(), cube.lineCount(), cube.bandCount(), cube.pixelType());
brick.SetBasePosition(1, 1, 1);
cube.read(brick);
data = new Buffer(brick);
fileString = filename.expanded();
}
示例8: 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->sampleCount(), icube->lineCount(),
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->bandCount());
// 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 {
QString msg = "Unknow value for INTERP [" +
ui.GetString("INTERP") + "]";
throw IException(IException::Programmer, msg, _FILEINFO_);
}
p.StartProcess(*transform, *interp);
p.EndProcess();
delete transform;
delete interp;
}
示例9: IsisMain
//.........这里部分代码省略.........
// Try a couple equivalent longitudes to fix the ordering of min,max for border cases
if ((double)outMappingGrp["MinimumLongitude"] >=
(double)outMappingGrp["MaximumLongitude"]) {
if ((QString)outMappingGrp["MinimumLongitude"] == "180.0" &&
(int)userMappingGrp["LongitudeDomain"] == 180)
outMappingGrp["MinimumLongitude"] = "-180";
if ((QString)outMappingGrp["MaximumLongitude"] == "-180.0" &&
(int)userMappingGrp["LongitudeDomain"] == 180)
outMappingGrp["MaximumLongitude"] = "180";
if ((QString)outMappingGrp["MinimumLongitude"] == "360.0" &&
(int)userMappingGrp["LongitudeDomain"] == 360)
outMappingGrp["MinimumLongitude"] = "0";
if ((QString)outMappingGrp["MaximumLongitude"] == "0.0" &&
(int)userMappingGrp["LongitudeDomain"] == 360)
outMappingGrp["MaximumLongitude"] = "360";
}
// 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")) {
QString msg = "Unable to determine the correct [MinimumLongitude,MaximumLongitude].";
msg += " Please specify these values in the [MINLON,MAXLON] parameters";
throw IException(IException::Unknown, 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.
TProjection *outproj = (TProjection *) 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->sampleCount(),
icube->lineCount(),
(TProjection *) 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->bandCount());
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 {
QString msg = "Unknow value for INTERP [" + ui.GetString("INTERP") + "]";
throw IException(IException::Programmer, msg, _FILEINFO_);
}
// Warp the cube
p.StartProcess(*transform, *interp);
p.EndProcess();
Application::Log(cleanOutGrp);
// Cleanup
delete transform;
delete interp;
}
示例10: IsisMain
/** The ISIS smtk main application */
void IsisMain() {
UserInterface &ui = Application::GetUserInterface();
// Open the first cube. It is the left hand image.
Cube lhImage;
CubeAttributeInput &attLeft = ui.GetInputAttribute("FROM");
vector<QString> bandLeft = attLeft.bands();
lhImage.setVirtualBands(bandLeft);
lhImage.open(ui.GetFileName("FROM"),"r");
// Open the second cube, it is geomertricallty altered. We will be matching the
// first to this one by attempting to compute a sample/line offsets
Cube rhImage;
CubeAttributeInput &attRight = ui.GetInputAttribute("MATCH");
vector<QString> bandRight = attRight.bands();
rhImage.setVirtualBands(bandRight);
rhImage.open(ui.GetFileName("MATCH"),"r");
// Ensure only single bands
if (lhImage.bandCount() != 1 || rhImage.bandCount() != 1) {
QString msg = "Input Cubes must have only one band!";
throw IException(IException::User,msg,_FILEINFO_);
}
// Both images must have a Camera and can also have a Projection. We will
// only deal with a Camera, however as a projected, non-mosaicked image
// uses a Projection internal to the Camera object.
Camera *lhCamera = NULL;
Camera *rhCamera = NULL;
try {
lhCamera = lhImage.camera();
rhCamera = rhImage.camera();
}
catch (IException &ie) {
QString msg = "Both input images must have a camera";
throw IException(ie, IException::User, msg, _FILEINFO_);
}
// Since we are generating a DEM, we must turn off any existing
// DEM that may have been initialized with spiceinit.
lhCamera->IgnoreElevationModel(true);
rhCamera->IgnoreElevationModel(true);
// Get serial number
QString serialLeft = SerialNumber::Compose(lhImage, true);
QString serialRight = SerialNumber::Compose(rhImage, true);
// This still precludes band to band registrations.
if (serialLeft == serialRight) {
QString sLeft = FileName(lhImage.fileName()).name();
QString sRight = FileName(rhImage.fileName()).name();
if (sLeft == sRight) {
QString msg = "Cube Serial Numbers must be unique - FROM=" + serialLeft +
", MATCH=" + serialRight;
throw IException(IException::User,msg,_FILEINFO_);
}
serialLeft = sLeft;
serialRight = sRight;
}
Progress prog;
prog.SetText("Finding Initial Seeds");
int nl = lhImage.lineCount();
int ns = lhImage.sampleCount();
BigInt numAttemptedInitialPoints = 0;
// Declare Gruen matcher
SmtkMatcher matcher(ui.GetFileName("REGDEF"), &lhImage, &rhImage);
// Get line/sample linc/sinc parameters
int space = ui.GetInteger("SPACE");
int linc (space), sinc(space);
// Do we have a seed points from a control net file?
bool useseed = ui.WasEntered("CNET");
// Base points on an input cnet
SmtkQStack gstack;
double lastEigen(0.0);
if (useseed) {
ControlNet cnet(ui.GetFileName("CNET"));
prog.SetMaximumSteps(cnet.GetNumPoints());
prog.CheckStatus();
gstack.reserve(cnet.GetNumPoints());
for (int cpIndex = 0; cpIndex < cnet.GetNumPoints(); cpIndex ++) {
ControlPoint *cp = cnet.GetPoint(cpIndex);
if (!cp->IsIgnored()) {
ControlMeasure *cmLeft(0), *cmRight(0);
for(int cmIndex = 0; cmIndex < cp->GetNumMeasures(); cmIndex ++) {
ControlMeasure *cm = cp->GetMeasure(cmIndex);
if (!cm->IsIgnored()) {
if (cm->GetCubeSerialNumber() == serialLeft)
cmLeft = cp->GetMeasure(cmIndex);
if (cm->GetCubeSerialNumber() == serialRight)
cmRight = cp->GetMeasure(cmIndex);
//.........这里部分代码省略.........
示例11: IsisMain
void IsisMain() {
try {
// We will be processing by line
ProcessByLine p;
double sscale, lscale;
int ins, inl, inb;
int ons, onl;
vector<QString> bands;
Cube inCube;
// To propogate labels, set input cube,
// this cube will be cleared after output cube is set.
p.SetInputCube("FROM");
// Setup the input and output cubes
UserInterface &ui = Application::GetUserInterface();
QString replaceMode = ui.GetAsString("VPER_REPLACE");
CubeAttributeInput cai(ui.GetAsString("FROM"));
bands = cai.bands();
inCube.setVirtualBands(bands);
QString from = ui.GetFileName("FROM");
inCube.open(from);
ins = inCube.sampleCount();
inl = inCube.lineCount();
inb = inCube.bandCount();
QString alg = ui.GetString("ALGORITHM");
double vper = ui.GetDouble("VALIDPER") / 100.;
if(ui.GetString("MODE") == "TOTAL") {
ons = ui.GetInteger("ONS");
onl = ui.GetInteger("ONL");
sscale = (double)ins / (double)ons;
lscale = (double)inl / (double)onl;
}
else {
sscale = ui.GetDouble("SSCALE");
lscale = ui.GetDouble("LSCALE");
ons = (int)((double)ins / sscale + 0.5);
onl = (int)((double)inl / lscale + 0.5);
}
if(ons > ins || onl > inl) {
QString msg = "Number of output samples/lines must be less than or equal";
msg = msg + " to the input samples/lines.";
throw IException(IException::User, msg, _FILEINFO_);
}
// Allocate output file
Cube *ocube = p.SetOutputCube("TO", ons, onl, inb);
// Our processing routine only needs 1
// the original set was for info about the cube only
p.ClearInputCubes();
// Start the processing
PvlGroup results;
if(alg == "AVERAGE"){
Average average(&inCube, sscale, lscale, vper, replaceMode);
p.ProcessCubeInPlace(average, false);
results = average.UpdateOutputLabel(ocube);
}
else if(alg == "NEAREST") {
Nearest near(&inCube, sscale, lscale);
p.ProcessCubeInPlace(near, false);
results = near.UpdateOutputLabel(ocube);
}
// Cleanup
inCube.close();
p.EndProcess();
// Write the results to the log
Application::Log(results);
} // REFORMAT THESE ERRORS INTO ISIS TYPES AND RETHROW
catch (IException &) {
throw;
}
catch (std::exception const &se) {
QString message = "std::exception: " + (QString)se.what();
throw IException(IException::User, message, _FILEINFO_);
}
catch (...) {
QString message = "Other Error";
throw IException(IException::User, message, _FILEINFO_);
}
}
示例12: IsisMain
void IsisMain() {
// Get the list of cubes to stack
Process p;
UserInterface &ui = Application::GetUserInterface();
FileList cubeList(ui.GetFileName("FROMLIST"));
// Loop through the list
int nsamps(0), nlines(0), nbands(0);
PvlGroup outBandBin("BandBin");
try {
for(int i = 0; i < cubeList.size(); i++) {
Cube cube;
CubeAttributeInput inatt(cubeList[i].original());
vector<QString> bands = inatt.bands();
cube.setVirtualBands(bands);
cube.open(cubeList[i].toString());
if(i == 0) {
nsamps = cube.sampleCount();
nlines = cube.lineCount();
nbands = cube.bandCount();
}
else {
// Make sure they are all the same size
if((nsamps != cube.sampleCount()) || (nlines != cube.lineCount())) {
QString msg = "Spatial dimensions of cube [" +
cubeList[i].toString() + "] does not match other cubes in list";
throw IException(IException::User, msg, _FILEINFO_);
}
// Get the total number of bands
nbands += cube.bandCount();
}
// Build up the band bin group
PvlObject &isiscube = cube.label()->findObject("IsisCube");
if(isiscube.hasGroup("BandBin")) {
PvlGroup &inBandBin = isiscube.findGroup("BandBin");
for(int key = 0; key < inBandBin.keywords(); key++) {
PvlKeyword &inKey = inBandBin[key];
if(!outBandBin.hasKeyword(inKey.name())) {
outBandBin += inKey;
}
else {
PvlKeyword &outKey = outBandBin[inKey.name()];
for(int index = 0; index < (int)inKey.size(); index++) {
outKey.addValue(inKey[index], inKey.unit(index));
}
}
}
}
cube.close();
}
}
catch(IException &e) {
QString msg = "Invalid cube in list file [" + ui.GetFileName("FROMLIST") + "]";
throw IException(e, IException::User, msg, _FILEINFO_);
}
// Setup to propagate from the first input cube
ProcessByLine p2;
CubeAttributeInput inatt;
int index = 0;
if(ui.WasEntered("PROPLAB")) {
bool match = false;
QString fname = ui.GetFileName("PROPLAB");
for(int i = 0; i < cubeList.size(); i++) {
if(fname == cubeList[i].toString()) {
index = i;
match = true;
break;
}
}
if(!match) {
QString msg = "FileName [" + ui.GetFileName("PROPLAB") +
"] to propagate labels from is not in the list file [" +
ui.GetFileName("FROMLIST") + "]";
throw IException(IException::User, msg, _FILEINFO_);
}
}
p2.SetInputCube(cubeList[index].toString(), inatt);
// Create the output cube
Cube *ocube = p2.SetOutputCube("TO", nsamps, nlines, nbands);
p2.ClearInputCubes();
p2.Progress()->SetText("Allocating cube");
p2.StartProcess(NullBand);
// Add the band bin group if necessary
if(outBandBin.keywords() > 0) {
ocube->putGroup(outBandBin);
}
p2.EndProcess();
// Now loop and mosaic in each cube
int sband = 1;
for(int i = 0; i < cubeList.size(); i++) {
ProcessMosaic m;
m.SetBandBinMatch(false);
//.........这里部分代码省略.........
示例13: IsisMain
void IsisMain () {
ResetGlobals();
UserInterface &ui = Application::GetUserInterface();
ProcessByBrick p;
Cube *icube = p.SetInputCube("FROM");
// Make sure it is a WAC cube
Isis::PvlGroup &inst = icube->label()->findGroup("Instrument", Pvl::Traverse);
QString instId = (QString) inst["InstrumentId"];
instId = instId.toUpper();
if (instId != "WAC-VIS" && instId != "WAC-UV") {
QString msg = "This program is intended for use on LROC WAC images only. [";
msg += icube->fileName() + "] does not appear to be a WAC image.";
throw IException(IException::User, msg, _FILEINFO_);
}
// And check if it has already run through calibration
if (icube->label()->findObject("IsisCube").hasGroup("Radiometry")) {
QString msg = "This image has already been calibrated";
throw IException(IException::User, msg, _FILEINFO_);
}
if (icube->label()->findObject("IsisCube").hasGroup("AlphaCube")) {
QString msg = "This application can not be run on any image that has been geometrically transformed (i.e. scaled, rotated, sheared, or reflected) or cropped.";
throw IException(IException::User, msg, _FILEINFO_);
}
g_dark = ui.GetBoolean("DARK");
g_flatfield = ui.GetBoolean("FLATFIELD");
g_radiometric = ui.GetBoolean("RADIOMETRIC");
g_iof = (ui.GetString("RADIOMETRICTYPE") == "IOF");
g_specpix = ui.GetBoolean("SPECIALPIXELS");
g_temprature = ui.GetBoolean("TEMPERATURE");
// Determine the dark/flat files to use
QString offset = (QString) inst["BackgroundOffset"];
QString mode = (QString) inst["Mode"];
QString instModeId = (QString) inst["InstrumentModeId"];
instModeId = instModeId.toUpper();
if (instModeId == "COLOR" && (QString) inst["InstrumentId"] == "WAC-UV")
instModeId = "UV";
else if (instModeId == "VIS")
instModeId = "COLOR";
g_startTemperature = (double) inst["BeginTemperatureFpa"];
g_endTemperature = (double) inst["EndTemperatureFpa"];
g_numFrames = (int) inst["NumFramelets"];
vector<QString> darkFiles;
ui.GetAsString("DARKFILE", darkFiles);
QString flatFile = ui.GetAsString("FLATFIELDFILE");
QString radFile = ui.GetAsString("RADIOMETRICFILE");
QString specpixFile = ui.GetAsString("SPECIALPIXELSFILE");
QString tempFile = ui.GetAsString("TEMPERATUREFILE");
// Figure out which bands are input
for (int i = 1; i <= icube->bandCount(); i++) {
g_bands.push_back(icube->physicalBand(i));
}
Isis::PvlGroup &bandBin = icube->label()->findGroup("BandBin", Pvl::Traverse);
QString filter = (QString) bandBin["Center"][0];
QString filterNum = (QString) bandBin["FilterNumber"][0];
//We have to pay special attention incase we are passed a
//single band image that has been "exploded" from a multiband wac
if (instModeId == "COLOR" && g_bands.size() == 1)
g_bands[0] = (toInt(filterNum) -2);
else if (instModeId == "UV" && g_bands.size() == 1)
g_bands[0] = (toInt(filterNum));
if (g_dark) {
if (darkFiles.size() == 0 || darkFiles[0] =="Default" || darkFiles[0].length() == 0) {
darkFiles.resize(2);
double temp = (double) inst["MiddleTemperatureFpa"];
double time = iTime(inst["StartTime"][0]).Et();
QString darkFile = "$lro/calibration/wac_darks/WAC_" + instModeId;
if (instModeId == "BW")
darkFile += "_" + filter + "_Mode" + mode;
darkFile += "_Offset" + offset + "_*C_*T_Dark.????.cub";
GetDark (darkFile, temp, time, g_darkCube1, g_darkCube2, g_temp1, g_temp2, darkFiles[0], darkFiles[1]);
}
else if (darkFiles.size() == 1) {
CopyCubeIntoBuffer(darkFiles[0], g_darkCube1);
g_temp1 = 0.0;
g_darkCube2 = new Buffer(*g_darkCube1);
g_temp2 = g_temp1;
}
else {
CopyCubeIntoBuffer(darkFiles[0], g_darkCube1);
int index = darkFiles[0].lastIndexOf("_");
g_temp1 = IString(darkFiles[0].mid( darkFiles[0].lastIndexOf("_", index-1), index)).ToDouble();
CopyCubeIntoBuffer(darkFiles[1], g_darkCube2);
index = darkFiles[1].lastIndexOf("_");
g_temp2 = IString(darkFiles[1].mid( darkFiles[1].lastIndexOf("_", index-1), index)).ToDouble();
}
}
//.........这里部分代码省略.........
示例14: IsisMain
void IsisMain() {
const QString caminfo_program = "caminfo";
UserInterface &ui = Application::GetUserInterface();
QList< QPair<QString, QString> > *general = NULL, *camstats = NULL, *statistics = NULL;
BandGeometry *bandGeom = NULL;
// Get input filename
FileName in = ui.GetFileName("FROM");
// Get the format
QString sFormat = ui.GetAsString("FORMAT");
// if true then run spiceinit, xml default is FALSE
// spiceinit will use system kernels
if(ui.GetBoolean("SPICE")) {
QString parameters = "FROM=" + in.expanded();
ProgramLauncher::RunIsisProgram("spiceinit", parameters);
}
Process p;
Cube *incube = p.SetInputCube("FROM");
// General data gathering
general = new QList< QPair<QString, QString> >;
general->append(MakePair("Program", caminfo_program));
general->append(MakePair("IsisVersion", Application::Version()));
general->append(MakePair("RunDate", iTime::CurrentGMT()));
general->append(MakePair("IsisId", SerialNumber::Compose(*incube)));
general->append(MakePair("From", in.baseName() + ".cub"));
general->append(MakePair("Lines", toString(incube->lineCount())));
general->append(MakePair("Samples", toString(incube->sampleCount())));
general->append(MakePair("Bands", toString(incube->bandCount())));
// Run camstats on the entire image (all bands)
// another camstats will be run for each band and output
// for each band.
if(ui.GetBoolean("CAMSTATS")) {
camstats = new QList< QPair<QString, QString> >;
QString filename = ui.GetAsString("FROM");
int sinc = ui.GetInteger("SINC");
int linc = ui.GetInteger("LINC");
CameraStatistics stats(filename, sinc, linc);
Pvl camPvl = stats.toPvl();
PvlGroup cg = camPvl.findGroup("Latitude", Pvl::Traverse);
camstats->append(MakePair("MinimumLatitude", cg["latitudeminimum"][0]));
camstats->append(MakePair("MaximumLatitude", cg["latitudemaximum"][0]));
cg = camPvl.findGroup("Longitude", Pvl::Traverse);
camstats->append(MakePair("MinimumLongitude", cg["longitudeminimum"][0]));
camstats->append(MakePair("MaximumLongitude", cg["longitudemaximum"][0]));
cg = camPvl.findGroup("Resolution", Pvl::Traverse);
camstats->append(MakePair("MinimumResolution", cg["resolutionminimum"][0]));
camstats->append(MakePair("MaximumResolution", cg["resolutionmaximum"][0]));
cg = camPvl.findGroup("PhaseAngle", Pvl::Traverse);
camstats->append(MakePair("MinimumPhase", cg["phaseminimum"][0]));
camstats->append(MakePair("MaximumPhase", cg["phasemaximum"][0]));
cg = camPvl.findGroup("EmissionAngle", Pvl::Traverse);
camstats->append(MakePair("MinimumEmission", cg["emissionminimum"][0]));
camstats->append(MakePair("MaximumEmission", cg["emissionmaximum"][0]));
cg = camPvl.findGroup("IncidenceAngle", Pvl::Traverse);
camstats->append(MakePair("MinimumIncidence", cg["incidenceminimum"][0]));
camstats->append(MakePair("MaximumIncidence", cg["incidencemaximum"][0]));
cg = camPvl.findGroup("LocalSolarTime", Pvl::Traverse);
camstats->append(MakePair("LocalTimeMinimum", cg["localsolartimeMinimum"][0]));
camstats->append(MakePair("LocalTimeMaximum", cg["localsolartimeMaximum"][0]));
}
// Compute statistics for entire cube
if(ui.GetBoolean("STATISTICS")) {
statistics = new QList< QPair<QString, QString> >;
LineManager iline(*incube);
Statistics stats;
Progress progress;
progress.SetText("Statistics...");
progress.SetMaximumSteps(incube->lineCount()*incube->bandCount());
progress.CheckStatus();
iline.SetLine(1);
for(; !iline.end() ; iline.next()) {
incube->read(iline);
stats.AddData(iline.DoubleBuffer(), iline.size());
progress.CheckStatus();
}
// Compute stats of entire cube
double nPixels = stats.TotalPixels();
double nullpercent = (stats.NullPixels() / (nPixels)) * 100;
double hispercent = (stats.HisPixels() / (nPixels)) * 100;
double hrspercent = (stats.HrsPixels() / (nPixels)) * 100;
double lispercent = (stats.LisPixels() / (nPixels)) * 100;
double lrspercent = (stats.LrsPixels() / (nPixels)) * 100;
//.........这里部分代码省略.........
示例15: IsisMain
// Main Program
void IsisMain() {
vector<double> filter;
int rowcol; // how many rows or cols per band
bool normalizeUsingAverage; // mult/sub using average or median?
int totalBands;
// Used for filtering the initial cubenorm averages and median values
int filtsize;
bool pause_crop;
int channel;
// ERROR CHECK: The user must specify at least the TO or STATS
// parameters.
UserInterface &ui = Application::GetUserInterface();
if(!(ui.WasEntered("TO")) && !(ui.WasEntered("STATS"))) {
QString msg = "User must specify a TO and/or STATS file.";
throw IException(IException::User, msg, _FILEINFO_);
}
// We will be processing by tile.
ProcessByTile p;
// Setup the input cube;
// Obtain information from the input file
Cube *icube = p.SetInputCube("FROM");
totalSamples = icube->sampleCount();
totalLines = icube->lineCount();
totalBands = icube->bandCount();
channel = icube->group("Instrument")["ChannelNumber"];
// Cubenorm New Version Flag
bool bNewVersion = ui.GetBoolean("NEW_VERSION");
// Setup the tile size for columnar processing
p.SetTileSize(1, totalLines);
rowcol = totalSamples;
// Gather statistics from the configured source
if(!bNewVersion && ui.GetString("STATSOURCE") == "CUBE") {
p.StartProcess(getStats);
}
else if(ui.GetString("STATSOURCE") == "TABLE") {
tableIn(ui.GetFileName("FROMSTATS"));
}
else {
PVLIn(ui.GetFileName("FROMSTATS"));
}
// Check to make sure the first vector has as many elements as the last
// vector, and that there is a vector element for each row/col
if(!bNewVersion && band.size() != (unsigned int)(rowcol * totalBands)) {
QString message = "You have entered an invalid input file " +
ui.GetFileName("FROMSTATS");
throw IException(IException::Io, message, _FILEINFO_);
}
// Get the information needed to filter the statistics
filtsize = ui.GetInteger("FILTER");
pause_crop = ui.GetBoolean("PAUSECROP");
if(bNewVersion) {
CorrectCubenormStats(filtsize, pause_crop, channel, ui.GetString("HIGHPASS_MODE"));
}
else {
// Filter the column averages
filter = average;
filterStats(filter, filtsize, pause_crop, channel);
average = filter;
// Filter the column medians
filter = median;
filterStats(filter, filtsize, pause_crop, channel);
median = filter;
}
// If a STATS file was specified then create statistics file
if(ui.WasEntered("STATS")) {
QString op = ui.GetString("FORMAT");
if(op == "PVL"){
pvlOut(ui.GetFileName("STATS"));
}
if(op == "TABLE"){
tableOut(ui.GetFileName("STATS"));
}
}
// Update the statistics vectors before creating the output
// file. Now get the statistics for each column
normalizeUsingAverage = ui.GetString("NORMALIZER") == "AVERAGE";
if(normalizeUsingAverage) {
normalizer = average;
}
else {
normalizer = median;
}
// If an output file was specified then normalize the cube
if(ui.WasEntered("TO")) {
// Before creating a normalized cube check to see if there
// are any column averages less than or equal to zero.
//.........这里部分代码省略.........