本文整理汇总了C++中FactoryResource::getCenterValues方法的典型用法代码示例。如果您正苦于以下问题:C++ FactoryResource::getCenterValues方法的具体用法?C++ FactoryResource::getCenterValues怎么用?C++ FactoryResource::getCenterValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FactoryResource
的用法示例。
在下文中一共展示了FactoryResource::getCenterValues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateResampledLibrary
bool SpectralLibraryManager::generateResampledLibrary(const RasterElement* pRaster)
{
VERIFY(pRaster != NULL);
// check that lib sigs are in same units as the raster element
const RasterDataDescriptor* pDesc = dynamic_cast<const RasterDataDescriptor*>(pRaster->getDataDescriptor());
VERIFY(pDesc != NULL);
const Units* pUnits = pDesc->getUnits();
if (pDesc->getUnits()->getUnitType() != mLibraryUnitType)
{
if (Service<DesktopServices>()->showMessageBox("Mismatched Units", "The data are not in the "
"same units as the spectral library.\n Do you want to continue anyway?", "Yes", "No") == 1)
{
return false;
}
}
FactoryResource<Wavelengths> pWavelengths;
pWavelengths->initializeFromDynamicObject(pRaster->getMetadata(), false);
// populate the library with the resampled signatures
PlugInResource pPlugIn("Resampler");
Resampler* pResampler = dynamic_cast<Resampler*>(pPlugIn.get());
VERIFY(pResampler != NULL);
if (pWavelengths->getNumWavelengths() != pDesc->getBandCount())
{
mpProgress->updateProgress("Wavelength information in metadata does not match the number of bands "
"in the raster element", 0, ERRORS);
return false;
}
// get resample suitable signatures - leave out signatures that don't cover the spectral range of the data
std::vector<std::vector<double> > resampledData;
resampledData.reserve(mSignatures.size());
std::vector<Signature*> resampledSignatures;
resampledSignatures.reserve(mSignatures.size());
std::vector<std::string> unsuitableSignatures;
std::vector<double> sigValues;
std::vector<double> sigWaves;
std::vector<double> rasterWaves = pWavelengths->getCenterValues();
std::vector<double> rasterFwhm = pWavelengths->getFwhm();
std::vector<double> resampledValues;
std::vector<int> bandIndex;
DataVariant data;
for (std::vector<Signature*>::const_iterator it = mSignatures.begin(); it != mSignatures.end(); ++it)
{
data = (*it)->getData(SpectralLibraryMatch::getNameSignatureWavelengthData());
VERIFY(data.isValid());
VERIFY(data.getValue(sigWaves));
resampledValues.clear();
data = (*it)->getData(SpectralLibraryMatch::getNameSignatureAmplitudeData());
VERIFY(data.isValid());
VERIFY(data.getValue(sigValues));
double scaleFactor = (*it)->getUnits(
SpectralLibraryMatch::getNameSignatureAmplitudeData())->getScaleFromStandard();
for (std::vector<double>::iterator sit = sigValues.begin(); sit != sigValues.end(); ++sit)
{
*sit *= scaleFactor;
}
std::string msg;
if (pResampler->execute(sigValues, resampledValues, sigWaves, rasterWaves, rasterFwhm, bandIndex, msg) == false
|| resampledValues.size() != rasterWaves.size())
{
unsuitableSignatures.push_back((*it)->getName());
continue;
}
resampledData.push_back(resampledValues);
resampledSignatures.push_back(*it);
}
if (resampledSignatures.empty())
{
std::string errMsg = "None of the signatures in the library cover the spectral range of the data.";
if (mpProgress != NULL)
{
mpProgress->updateProgress(errMsg, 0, ERRORS);
return false;
}
}
if (unsuitableSignatures.empty() == false)
{
std::string warningMsg = "The following library signatures do not cover the spectral range of the data:\n";
for (std::vector<std::string>::iterator it = unsuitableSignatures.begin();
it != unsuitableSignatures.end(); ++it)
{
warningMsg += *it + "\n";
}
warningMsg += "These signatures will not be searched for in the data.";
Service<DesktopServices>()->showMessageBox("SpectralLibraryManager", warningMsg);
StepResource pStep("Spectral LibraryManager", "spectral", "64B6C87A-A6C3-4378-9B6E-221D89D8707B");
pStep->finalize(Message::Unresolved, warningMsg);
}
std::string libName = "Resampled Spectral Library";
// Try to get the resampled lib element in case session was restored. If NULL, create a new raster element with
// num rows = num valid signatures, num cols = 1, num bands = pRaster num bands
//.........这里部分代码省略.........
示例2: execute
//.........这里部分代码省略.........
if (pLayerList != NULL)
{
pElement = pLayerList->getPrimaryRasterElement();
pWavelengths->initializeFromDynamicObject(pElement->getMetadata(), false);
if (pWavelengths->isEmpty())
{
progress.report("No target wavelengths are available for resampling the signatures.", 0, ERRORS, true);
return false;
}
resampledTo = pElement->getName();
}
}
}
PlugInResource pPlugIn("Resampler");
Resampler* pResampler = dynamic_cast<Resampler*>(pPlugIn.get());
if (pResampler == NULL)
{
progress.report("The \"Resampler\" plug-in is not available so the signatures can not be resampled.",
0, ERRORS, true);
return false;
}
std::string dataName("Reflectance");
std::string wavelengthName("Wavelength");
// save user config settings - Resampler doesn't have interface to set them separately from user config
std::string configMethod = ResamplerOptions::getSettingResamplerMethod();
ResamplerOptions::setSettingResamplerMethod(resampleMethod);
double configDropout = ResamplerOptions::getSettingDropOutWindow();
ResamplerOptions::setSettingDropOutWindow(dropOutWindow);
double configFwhm = ResamplerOptions::getSettingFullWidthHalfMax();
ResamplerOptions::setSettingFullWidthHalfMax(fwhm);
std::vector<double> toWavelengths = pWavelengths->getCenterValues();
std::vector<double> toFwhm = pWavelengths->getFwhm();
if (toFwhm.size() != toWavelengths.size())
{
toFwhm.clear(); // Resampler will use the default config setting fwhm if this vector is empty
}
unsigned int numSigs = originalSignatures.size();
unsigned int numSigsResampled(0);
progress.report("Begin resampling signatures...", 0, NORMAL);
for (unsigned int index = 0; index < numSigs; ++index)
{
if (isAborted())
{
progress.report("Resampling aborted by user", 100 * index / numSigs, ABORT, true);
return false;
}
if (originalSignatures[index] == NULL)
{
continue;
}
// check if signature has target wavelength centers and doesn't need to be resampled
if (needToResample(originalSignatures[index], pWavelengths.get()) == false)
{
pResampledSignatures->push_back(originalSignatures[index]);
++numSigsResampled;
continue;
}
DataVariant var = originalSignatures[index]->getData(dataName);
if (var.isValid() == false)
{
示例3: createAverageSignature
void SpectralLibraryMatchResults::createAverageSignature()
{
Service<DesktopServices> pDesktop;
const RasterElement* pRaster = getRasterElementForCurrentPage();
if (pRaster == NULL)
{
pDesktop->showMessageBox("Spectral Library Match",
"Unable to determine the RasterElement for the current page.");
return;
}
std::vector<Signature*> signatures = getSelectedSignatures();
if (signatures.empty())
{
pDesktop->showMessageBox("Spectral Library Match",
"No signatures are selected for use in generating an average signature.");
return;
}
// now need to get the resampled sigs from the library
SpectralLibraryManager* pLibMgr(NULL);
std::vector<PlugIn*> plugIns =
Service<PlugInManagerServices>()->getPlugInInstances(SpectralLibraryMatch::getNameLibraryManagerPlugIn());
if (!plugIns.empty())
{
pLibMgr = dynamic_cast<SpectralLibraryManager*>(plugIns.front());
}
if (pLibMgr == NULL)
{
pDesktop->showMessageBox("Spectral Library Match",
"Unable to access the Spectral Library Manager.");
return;
}
const RasterDataDescriptor* pDesc = dynamic_cast<const RasterDataDescriptor*>(pRaster->getDataDescriptor());
if (pDesc == NULL)
{
pDesktop->showMessageBox("Spectral Library Match",
"Unable to access the RasterDataDescriptor for the RasterElement of the current page.");
return;
}
unsigned int numBands = pDesc->getBandCount();
std::vector<double> averageValues(numBands, 0);
std::vector<double> values;
for (std::vector<Signature*>::iterator it = signatures.begin(); it != signatures.end(); ++it)
{
if (pLibMgr->getResampledSignatureValues(pRaster, *it, values) == false)
{
pDesktop->showMessageBox("Spectral Library Match",
"Unable to access the resampled signature values for " + (*it)->getDisplayName(true));
return;
}
for (unsigned int band = 0; band < numBands; ++band)
{
averageValues[band] += values[band];
}
}
unsigned int numSigs = signatures.size();
for (unsigned int band = 0; band < numBands; ++band)
{
averageValues[band] /= static_cast<double>(numSigs);
}
QString avgName = QInputDialog::getText(pDesktop->getMainWidget(), "Spectral Library Match",
"Enter the name to use for the average signature:");
if (avgName.isEmpty())
{
return;
}
ModelResource<Signature> pAvgSig(avgName.toStdString(), const_cast<RasterElement*>(pRaster));
pAvgSig->setData("Reflectance", averageValues);
const DynamicObject* pMetaData = pRaster->getMetadata();
FactoryResource<Wavelengths> pWavelengths;
pWavelengths->initializeFromDynamicObject(pMetaData, false);
const std::vector<double>& centerValues = pWavelengths->getCenterValues();
pAvgSig->setData("Wavelength", centerValues);
SignatureDataDescriptor* pSigDesc = dynamic_cast<SignatureDataDescriptor*>(pAvgSig->getDataDescriptor());
VERIFYNRV(pSigDesc != NULL);
FactoryResource<Units> pUnits;
const Units* pRasterUnits = pDesc->getUnits();
pUnits->setUnitName(pRasterUnits->getUnitName());
pUnits->setUnitType(pRasterUnits->getUnitType());
pUnits->setScaleFromStandard(1.0); // the rescaled values are already corrected for the original scaling factor
pUnits->setRangeMin(pRasterUnits->getRangeMin());
pUnits->setRangeMax(pRasterUnits->getRangeMax());
pSigDesc->setUnits("Reflectance", pUnits.get());
pAvgSig.release();
}