本文整理汇总了C++中Cube::PixelType方法的典型用法代码示例。如果您正苦于以下问题:C++ Cube::PixelType方法的具体用法?C++ Cube::PixelType怎么用?C++ Cube::PixelType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cube
的用法示例。
在下文中一共展示了Cube::PixelType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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");
}
示例2: InitializeFromCube
void Histogram::InitializeFromCube(Cube &cube, const int band, Progress *progress) {
// Make sure band is valid
if ((band < 0) || (band > cube.Bands())) {
string msg = "Invalid band in [Histogram constructor]";
throw Isis::iException::Message(Isis::iException::Programmer,msg,_FILEINFO_);
}
double min,max;
int nbins;
if (cube.PixelType() == Isis::UnsignedByte) {
min = 0.0 * cube.Multiplier() + cube.Base();
max = 255.0 * cube.Multiplier() + cube.Base();
nbins = 256;
}
else if (cube.PixelType() == Isis::SignedWord) {
min = -32768.0 * cube.Multiplier() + cube.Base();
max = 32767.0 * cube.Multiplier() + cube.Base();
nbins = 65536;
}
else if (cube.PixelType() == Isis::Real) {
// Determine the band for statistics
int bandStart = band;
int bandStop = band;
int maxSteps = cube.Lines();
if (band == 0){
bandStart = 1;
bandStop = cube.Bands();
maxSteps = cube.Lines() * cube.Bands();
}
// Construct a line buffer manager and a statistics object
LineManager line(cube);
Statistics stats = Statistics();
// Prep for reporting progress if necessary
if (progress != NULL) {
string save = progress->Text ();
progress->SetText("Computing min/max for histogram");
progress->SetMaximumSteps(maxSteps);
progress->CheckStatus();
}
for (int useBand = bandStart ; useBand <= bandStop ; useBand++){
// Loop and get the statistics for a good minimum/maximum
for (int i=1; i<=cube.Lines(); i++) {
line.SetLine(i,useBand);
cube.Read(line);
stats.AddData (line.DoubleBuffer(),line.size());
if (progress != NULL) progress->CheckStatus();
}
}
// Get the min/max for constructing a histogram object
if (stats.ValidPixels() == 0) {
min = 0.0;
max = 1.0;
}
else {
min = stats.BestMinimum ();
max = stats.BestMaximum ();
}
nbins = 65536;
}
else {
std::string msg = "Unsupported pixel type";
throw iException::Message(Isis::iException::Programmer,msg,_FILEINFO_);
}
// Set the bins and range
SetBinRange(min,max);
SetBins(nbins);
}
示例3: 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
//.........这里部分代码省略.........