本文整理汇总了C++中RasterElement::getStatistics方法的典型用法代码示例。如果您正苦于以下问题:C++ RasterElement::getStatistics方法的具体用法?C++ RasterElement::getStatistics怎么用?C++ RasterElement::getStatistics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RasterElement
的用法示例。
在下文中一共展示了RasterElement::getStatistics方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getExportOptionsWidget
QWidget* ResultsExporter::getExportOptionsWidget(const PlugInArgList *pInArgList)
{
const DataDescriptor* pDescriptor = NULL;
if (pInArgList != NULL)
{
RasterElement* pElement = pInArgList->getPlugInArgValue<RasterElement>(Exporter::ExportItemArg());
if (pElement != NULL)
{
pDescriptor = pElement->getDataDescriptor();
}
}
if (mpOptionsWidget == NULL)
{
Service<DesktopServices> pDesktop;
VERIFY(pDesktop.get() != NULL);
mpOptionsWidget = new ResultsOptionsWidget(pDesktop->getMainWidget());
}
if (mpOptionsWidget != NULL)
{
const string& name = pDescriptor->getName();
const string& type = pDescriptor->getType();
DataElement* pParent = pDescriptor->getParent();
RasterElement* pResults = dynamic_cast<RasterElement*>(mpModel->getElement(name, type, pParent));
if (pResults != NULL)
{
PassArea passArea = MIDDLE;
double dFirstThreshold = 0.0;
double dSecondThreshold = 0.0;
SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(mpDesktop->getCurrentWorkspaceWindow());
if (pWindow != NULL)
{
SpatialDataView* pView = pWindow->getSpatialDataView();
if (pView != NULL)
{
LayerList* pLayerList = pView->getLayerList();
if (pLayerList != NULL)
{
ThresholdLayer* pThresholdLayer =
static_cast<ThresholdLayer*>(pLayerList->getLayer(THRESHOLD, pResults));
if (pThresholdLayer != NULL)
{
passArea = pThresholdLayer->getPassArea();
dFirstThreshold = pThresholdLayer->getFirstThreshold();
dSecondThreshold = pThresholdLayer->getSecondThreshold();
}
else
{
Statistics* pStatistics = pResults->getStatistics();
if (pStatistics != NULL)
{
dFirstThreshold = pStatistics->getMin();
dSecondThreshold = pStatistics->getMax();
}
}
}
LatLonLayer* pLatLonLayer = static_cast<LatLonLayer*>(pView->getTopMostLayer(LAT_LONG));
if (pLatLonLayer != NULL)
{
GeocoordType geocoordType = pLatLonLayer->getGeocoordType();
mpOptionsWidget->setGeocoordType(geocoordType);
}
}
}
mpOptionsWidget->setPassArea(passArea);
mpOptionsWidget->setFirstThreshold(dFirstThreshold);
mpOptionsWidget->setSecondThreshold(dSecondThreshold);
}
}
return mpOptionsWidget;
}
示例2: createRasterElement
DataElement* createRasterElement(const char* pName, RasterElementArgs args)
{
if (pName == NULL || args.location > 2)
{
setLastError(SIMPLE_BAD_PARAMS);
return NULL;
}
// Check for an existing element with the name
if (getDataElement(pName, TypeConverter::toString<RasterElement>(), 0) != NULL)
{
setLastError(SIMPLE_EXISTS);
return NULL;
}
RasterElement* pElement = RasterUtilities::createRasterElement(std::string(pName), args.numRows,
args.numColumns, args.numBands, static_cast<EncodingTypeEnum>(args.encodingType),
static_cast<InterleaveFormatTypeEnum>(args.interleaveFormat), args.location != 2, args.pParent);
if (pElement == NULL)
{
switch (args.location)
{
case 0:
pElement = RasterUtilities::createRasterElement(std::string(pName), args.numRows,
args.numColumns, args.numBands, static_cast<EncodingTypeEnum>(args.encodingType),
static_cast<InterleaveFormatTypeEnum>(args.interleaveFormat), false, args.pParent);
if (pElement == NULL)
{
setLastError(SIMPLE_OTHER_FAILURE);
return NULL;
}
break;
case 1:
setLastError(SIMPLE_NO_MEM);
return NULL;
case 2:
setLastError(SIMPLE_OTHER_FAILURE);
return NULL;
default:
setLastError(SIMPLE_BAD_PARAMS);
return NULL;
}
}
if (args.pBadValues != NULL && args.numBadValues > 0)
{
RasterDataDescriptor* pDesc = static_cast<RasterDataDescriptor*>(pElement->getDataDescriptor());
if (pDesc != NULL)
{
std::vector<int> badValues;
badValues.reserve(args.numBadValues);
for (uint32_t idx = 0; idx < args.numBadValues; ++idx)
{
badValues.push_back(args.pBadValues[idx]);
}
pDesc->setBadValues(badValues);
// set on the statistics objects
const std::vector<DimensionDescriptor>& allBands = pDesc->getBands();
for (std::vector<DimensionDescriptor>::const_iterator band = allBands.begin();
band != allBands.end(); ++band)
{
if (band->isValid())
{
Statistics* pStats = pElement->getStatistics(*band);
if (pStats != NULL)
{
pStats->setBadValues(badValues);
}
}
}
pElement->updateData();
}
}
setLastError(SIMPLE_NO_ERROR);
return pElement;
}
示例3: execute
bool RasterTimingTest::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
if (isBatch())
{
VERIFY(pOutArgList != NULL);
}
Service<DesktopServices> pDesktop;
SpatialDataView* pView = dynamic_cast<SpatialDataView*>(pDesktop->getCurrentWorkspaceWindowView());
if (pView)
{
UndoLock lock(pView);
RasterElement* pElement = pView->getLayerList()->getPrimaryRasterElement();
RasterDataDescriptor* pDesc = dynamic_cast<RasterDataDescriptor*>(pElement->getDataDescriptor());
int bands = pDesc->getBandCount();
int frameNumber = 0;
RasterLayer* pLayer = NULL;
vector<Layer*> layers;
pView->getLayerList()->getLayers(RASTER, layers);
for (vector<Layer*>::iterator iter = layers.begin(); iter != layers.end(); ++iter)
{
RasterLayer* pRasterLayer = static_cast<RasterLayer*>(*iter);
if (pRasterLayer != NULL)
{
RasterElement* pCurrentRasterElement = dynamic_cast<RasterElement*>(pRasterLayer->getDataElement());
if (pCurrentRasterElement == pElement)
{
pLayer = pRasterLayer;
break;
}
}
}
for (int i = 0; i < bands; ++i)
{
pElement->getStatistics(pDesc->getActiveBand(i))->getMin();
}
// set grayscale display mode
DisplayMode initialDisplayMode = pLayer->getDisplayMode();
pLayer->setDisplayMode(GRAYSCALE_MODE);
const int frameiterations = 10000;
clock_t startTime = clock();
QWidget* pWidget = pView->getWidget();
int i = 0;
for (i = 0; i < frameiterations; ++i, ++frameNumber)
{
if (frameNumber >= bands)
{
frameNumber = 0;
}
pLayer->setDisplayedBand(GRAY, pDesc->getActiveBand(frameNumber));
if (pWidget)
{
pWidget->repaint();
}
if ((i + 1) % (frameiterations / 100) == 0)
{
QString message = QString("Frame ") + QString::number(i+1) + QString(" of ") +
QString::number(frameiterations);
pDesktop->setStatusBarMessage(message.toStdString());
}
if ((i + 1) % 20 == 0)
{
clock_t stopTime = clock();
double elapsedTime = static_cast<double>(stopTime - startTime) / CLOCKS_PER_SEC;
if (elapsedTime > 30)
{
++i;
break;
}
}
}
clock_t stopTime = clock();
double framesPerSec = i / (static_cast<double>(stopTime - startTime) / CLOCKS_PER_SEC);
// restore display mode
pLayer->setDisplayMode(initialDisplayMode);
if (isBatch())
{
pOutArgList->setPlugInArgValue<double>("Framerate", &framesPerSec);
}
else
{
QMessageBox::information(pDesktop->getMainWidget(), "Frame Rate",
QString("The number of frames per second was: %1\nGPU Acceleration was%2 enabled\n").arg(framesPerSec)
.arg(pLayer->isGpuImageEnabled() ? "" : " not"));
}
return true;
}
return false;
}
示例4: processAll
//.........这里部分代码省略.........
pWavelengths.reset(new Wavelengths(pMetadata));
if (!pWavelengths->isEmpty() && (!pWavelengths->hasEndValues() || !pWavelengths->hasStartValues()))
{
pWavelengths->calculateFwhm();
}
}
VERIFY(pWavelengths.get() != NULL);
int sig_index = 0;
bool bSuccess = true;
if (mInputs.mSignatures.empty())
{
progress.report(ACEERR005, 0, ERRORS, true);
return false;
}
int iSignatureCount = mInputs.mSignatures.size();
// Create a vector for the signature names
vector<string> sigNames;
RasterElement* pResults = NULL;
bool resultsIsTemp = false;
Signature* pSignature = mInputs.mSignatures[sig_index];
sigNames.push_back(pSignature->getName());
std::string rname = mInputs.mResultsName;
if (iSignatureCount > 1 && !mInputs.mbCreatePseudocolor)
{
rname += " " + sigNames.back();
}
else if (iSignatureCount > 1)
{
rname += "AceTemp";
resultsIsTemp = true;
}
pResults = createResults(numRows, numColumns, rname);
if (pResults == NULL)
{
return false;
}
vector<double> spectrumValues;
vector<int> resampledBands;
bSuccess = resampleSpectrum(pSignature, spectrumValues, *pWavelengths.get(), resampledBands);
// Check for limited spectral coverage and warning log
if (bSuccess && pWavelengths->hasCenterValues() &&
resampledBands.size() != pWavelengths->getCenterValues().size())
{
QString buf = QString("Warning AceAlg014: The spectrum only provides spectral coverage for %1 of %2 bands.")
.arg(resampledBands.size()).arg(pWavelengths->getCenterValues().size());
progress.report(buf.toStdString(), 0, WARNING, true);
}
BitMaskIterator iterChecker(getPixelsToProcess(), pElement);
EncodingType type = pDescriptor->getDataType();
switchOnEncoding(type, aceAlg, NULL, pElement, pResults, spectrumValues, mpProgress);
/////////////////////////////////////////////////////
vector<ColorType> layerColors, excludeColors;
excludeColors.push_back(ColorType(0, 0, 0));
excludeColors.push_back(ColorType(255, 255, 255));
ColorType::getUniqueColors(iSignatureCount, layerColors, excludeColors);
ColorType color;
if (0 <= static_cast<int>(layerColors.size()))
{
color = layerColors[0];
}
double dMaxValue = pResults->getStatistics()->getMax();
// Displays results for current signature
displayThresholdResults(pResults, color, UPPER, mInputs.mThreshold, dMaxValue, layerOffset);
// displayThresholdResults(pResults, color, UPPER, 0.6, dMaxValue, layerOffset);
//////////////////////////////////////////////////////
/*
Service<DesktopServices> pDesktop;
SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(pDesktop->createWindow(rname,
SPATIAL_DATA_WINDOW));
SpatialDataView* pView = (pWindow == NULL) ? NULL : pWindow->getSpatialDataView();
if (pView == NULL)
{
std::string msg = "Unable to create view.";
progress.report(msg, 0, ERRORS, true);
return false;
}
pView->setPrimaryRasterElement(pResults);
pView->createLayer(RASTER, pResults);
*/
return true;
}
示例5: ensureStatisticsReadProperly
bool SioImporter::ensureStatisticsReadProperly(Progress *pProgress, std::ostream& failure)
{
bool success = true;
success &= setBatch();
PlugInArgList* pInList = NULL;
PlugInArgList* pOutList = NULL;
isseas(getInputSpecification(pInList) != false, failure);
isseas(getOutputSpecification(pOutList) != false, failure);
PlugInArg* pRasterElementArg = NULL;
isseas(pInList->getArg(Importer::ImportElementArg(), pRasterElementArg) != false, failure);
string testFilePath = TestUtilities::getTestDataPath() + "tipjul5bands.sio";
RasterElement* pRasterElement = NULL;
if (success)
{
vector<ImportDescriptor*> descriptors = getImportDescriptors(testFilePath);
if (descriptors.empty() == false)
{
ImportDescriptor* pImportDescriptor = descriptors.front();
if (pImportDescriptor != NULL)
{
DataDescriptor* pDescriptor = pImportDescriptor->getDataDescriptor();
if (pDescriptor != NULL)
{
Service<ModelServices> pModel;
pRasterElement = dynamic_cast<RasterElement*>(pModel->createElement(pDescriptor));
if (pRasterElement != NULL)
{
pRasterElementArg->setActualValue(pRasterElement);
}
}
}
}
}
isseas(execute(pInList, pOutList) != false, failure);
isseas(pRasterElement != NULL, failure);
if (success)
{
RasterDataDescriptor* pDescriptor = dynamic_cast<RasterDataDescriptor*>(pRasterElement->getDataDescriptor());
isseas(pDescriptor != NULL, failure);
const vector<DimensionDescriptor>& loadedBands = pDescriptor->getBands();
isseas(loadedBands.size() == 5, failure);
int iNumBandsWithStats = 0;
for (int i = 0; i < 5; ++i)
{
// we don't want to do an assert yet... only when we know 4 bands have computed statistics
Statistics* pStatistics = pRasterElement->getStatistics(loadedBands[i]);
if (pStatistics != NULL)
{
if (pStatistics->areStatisticsCalculated() == true)
{
if (success)
{
iNumBandsWithStats++;
}
}
}
}
// success of the band computation is dependent on 4 bands with statistics
isseas(iNumBandsWithStats == 3, failure);
}
if (pRasterElement != NULL)
{
Service<ModelServices> pModel;
pModel->destroyElement(pRasterElement);
pRasterElement = NULL;
}
Service<PlugInManagerServices> pPim;
if (pInList)
{
pPim->destroyPlugInArgList(pInList);
}
if (pOutList)
{
pPim->destroyPlugInArgList(pOutList);
}
return success;
}
示例6: execute
bool SioImporter::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
// Read the statistics from the file and set into the raster element
RasterElement* pRaster = NULL;
if (pInArgList != NULL)
{
pRaster = pInArgList->getPlugInArgValue<RasterElement>(Importer::ImportElementArg());
}
if (pRaster != NULL)
{
// Get the filename
string filename = pRaster->getFilename();
// Read the file
FileResource pFile(filename.c_str(), "rb");
SioFile sioFile;
if (sioFile.deserialize(pFile.get()) == true)
{
if (sioFile.mOriginalVersion == 9 && isBatch())
{
//Since version 9 sio's are not officially supported
//don't load them in batch to force users to load them
//interactively which will show them the reason why.
return false;
}
const RasterDataDescriptor* pDescriptor =
dynamic_cast<const RasterDataDescriptor*>(pRaster->getDataDescriptor());
if (pDescriptor != NULL &&
RasterUtilities::isSubcube(pDescriptor, false) == false &&
Service<SessionManager>()->isSessionLoading() == false)
{
const vector<DimensionDescriptor>& bands = pDescriptor->getBands();
for (unsigned int i = 0; i < bands.size(); ++i)
{
Statistics* pStatistics = pRaster->getStatistics(bands[i]);
if (pStatistics != NULL)
{
// Bad values
if (i < sioFile.mBadValues.size())
{
vector<int> badValues = sioFile.mBadValues[i];
pStatistics->setBadValues(badValues);
}
// Min
if (i < sioFile.mStatMin.size())
{
double dMin = sioFile.mStatMin[i];
pStatistics->setMin(dMin);
}
// Max
if (i < sioFile.mStatMax.size())
{
double dMax = sioFile.mStatMax[i];
pStatistics->setMax(dMax);
}
// Average
if (i < sioFile.mStatAvg.size())
{
double dAverage = sioFile.mStatAvg[i];
pStatistics->setAverage(dAverage);
}
// Standard deviation
if (i < sioFile.mStatStdDev.size())
{
double dStdDev = sioFile.mStatStdDev[i];
pStatistics->setStandardDeviation(dStdDev);
}
// Percentiles
if (i < sioFile.mStatPercentile.size())
{
double* pPercentiles = sioFile.mStatPercentile[i];
pStatistics->setPercentiles(pPercentiles);
}
// Histogram
if ((i < sioFile.mStatBinCenter.size()) && (i < sioFile.mStatHistogram.size()))
{
double* pBinCenters = sioFile.mStatBinCenter[i];
unsigned int* pCounts = sioFile.mStatHistogram[i];
pStatistics->setHistogram(pBinCenters, pCounts);
}
}
}
}
}
}
return RasterElementImporterShell::execute(pInArgList, pOutArgList);
}
示例7: processAll
//.........这里部分代码省略.........
{
Service<ModelServices>()->destroyElement(pResults);
progress.report("Unable to access data.", 0, ERRORS, true);
return false;
}
daPseudoAccessor->toPixel(row_ctr, col_ctr);
daCurrentAccessor->toPixel(row_ctr, col_ctr);
pPseudoValue = reinterpret_cast<float*>(daPseudoAccessor->getColumn());
pCurrentValue = reinterpret_cast<float*>(daCurrentAccessor->getColumn());
daLowestSAMValue->toPixel(row_ctr, col_ctr);
pLowestValue = reinterpret_cast<float*>(daLowestSAMValue->getColumn());
if (*pCurrentValue <= mInputs.mThreshold)
{
if (*pCurrentValue < *pLowestValue)
{
*pPseudoValue = sig_index+1;
*pLowestValue = *pCurrentValue;
}
}
}
}
}
else
{
ColorType color;
if (sig_index <= static_cast<int>(layerColors.size()))
{
color = layerColors[sig_index];
}
double dMaxValue = pResults->getStatistics()->getMax();
// Displays results for current signature
displayThresholdResults(pResults, color, LOWER, mInputs.mThreshold, dMaxValue, layerOffset);
}
//If we are on the last signature then destroy the lowest value Matrix
if (sig_index == iSignatureCount-1)
{
if (pLowestSAMValueMatrix != NULL)
{
Service<ModelServices>()->destroyElement(pLowestSAMValueMatrix);
pLowestSAMValueMatrix = NULL;
}
}
}
} //End of Signature Loop Counter
if (resultsIsTemp || !bSuccess)
{
Service<ModelServices>()->destroyElement(pResults);
pResults = NULL;
}
if (bSuccess)
{
// Displays final Pseudocolor output layer results
if ((isInteractive() || mInputs.mbDisplayResults) && iSignatureCount > 1 && mInputs.mbCreatePseudocolor)
{
displayPseudocolorResults(pPseudocolorMatrix, sigNames, layerOffset);
}
}