本文整理汇总了C++中Statistics::BestMaximum方法的典型用法代码示例。如果您正苦于以下问题:C++ Statistics::BestMaximum方法的具体用法?C++ Statistics::BestMaximum怎么用?C++ Statistics::BestMaximum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statistics
的用法示例。
在下文中一共展示了Statistics::BestMaximum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeStretch
//! Compute automatic stretch for a portion of the cube
void ChipViewport::computeStretch(Stretch &stretch, bool force) {
if (p_stretchLocked && !force) {
stretch = *p_stretch;
}
else {
Statistics stats;
for (int line = 1; line < p_chip->Lines(); line++) {
for (int samp = 1; samp < p_chip->Samples(); samp++) {
double value = p_chip->GetValue(samp, line);
stats.AddData(&value, 1);
}
}
Histogram hist(stats.BestMinimum(), stats.BestMaximum());
for (int line = 1; line <= p_chip->Lines(); line++) {
for (int samp = 1; samp <= p_chip->Samples(); samp++) {
double value = p_chip->GetValue(samp, line);
hist.AddData(&value, 1);
}
}
stretch.ClearPairs();
if (hist.Percent(0.5) != hist.Percent(99.5)) {
stretch.AddPair(hist.Percent(0.5), 0.0);
stretch.AddPair(hist.Percent(99.5), 255.0);
}
else {
stretch.AddPair(-DBL_MAX, 0.0);
stretch.AddPair(DBL_MAX, 255.0);
}
*p_stretch = stretch;
}
}
示例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);
}