本文整理汇总了C++中Labels::getShadeLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ Labels::getShadeLevel方法的具体用法?C++ Labels::getShadeLevel怎么用?C++ Labels::getShadeLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Labels
的用法示例。
在下文中一共展示了Labels::getShadeLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillMissingLabels
//! compare two labels and fill in missing labels
void ShadeShapeMatch::fillMissingLabels(Labels &upLabels, Labels &dbLabels) {
map<String,pair<int,float> > &upMap = upLabels.getMap();
map<String,pair<int,float> > &dbMap = dbLabels.getMap();
map<String,int> &upShadeLevelMap = upLabels.getShadeLevelMap();
map<String,int> &dbShadeLevelMap = dbLabels.getShadeLevelMap();
map<String,int> &upShapeNumMap = upLabels.getShapeMap();
map<String,int> &dbShapeNumMap = dbLabels.getShapeMap();
for(auto it=upMap.begin(); it!=upMap.end(); it++) {
String label = it->first;
if(dbMap.find(label)==dbMap.end()) {
dbMap[label] = std::make_pair(0,0.0);
dbShadeLevelMap[label] = upLabels.getShadeLevel(label);
dbShapeNumMap[label] = upLabels.getShapeNum(label);
}
}
for(auto it=dbMap.begin(); it!=dbMap.end(); it++) {
String label = it->first;
if(upMap.find(label)==upMap.end()) {
upMap[label] = std::make_pair(0,0.0);
upShadeLevelMap[label] = dbLabels.getShadeLevel(label);
upShapeNumMap[label] = dbLabels.getShapeNum(label);
}
}
}
示例2: dotProduct
//! dot product using holder's inequality
//! TR1
//! applies shape shift penalties during calculations for the shapes shifted
float ShadeShapeMatch::dotProduct(Labels &upLabels, Labels &dbLabels) {
ShapeMatch spm;
ShadeMatch sdm;
if(upLabels.size()!=dbLabels.size()) {
cout << "ShapeMatch::dotProduct(): upLabels && dbLabels not same size!!!" << endl;
exit(1);
}
float numerSum = 0.0;
float denomSumUP = 0.0;
float denomSumDB = 0.0;
map<String,pair<int,float> > upMap = upLabels.getMap();
map<String,pair<int,float> > dbMap = dbLabels.getMap();
this->shapeTranslateCount.resize(spm.numOfShapes(),vector<int>(spm.numOfShapes(),0)); // 10 shapes
for(auto itUP=upMap.begin(), itDB=dbMap.begin(); itUP!=upMap.end(), itDB!=dbMap.end(); itUP++, itDB++) {
String label = itUP->first;
float penalty = 1.0;
int shapeNum = upLabels.getShapeNum(label);
if(shapeNum==-1) shapeNum = dbLabels.getShapeNum(label);
if(upLabels.isShapeShifted(label)) {
int prevShapeNum = upLabels.getPrevShapeNum(label);
if(prevShapeNum>=0 && shapeNum>=0) {
penalty = spm.getShiftPenalty(prevShapeNum,shapeNum);
} else {
printf("ShadeShapeMatch::dotProduct() %s label does not exist!\n",itUP->first.c_str());
printf("PrevShapeNum: %d, :CurrShapeNum: %d\n",prevShapeNum,shapeNum);
}
}
int shadeLevel = upLabels.getShadeLevel(label);
float shadeWeight = sdm.applyShadeWeights(shadeLevel);
float shapeWeight = spm.applyShapeWeight(shapeNum);
numerSum += (itUP->second.second * itDB->second.second) * penalty * shadeWeight * shapeWeight;
denomSumUP += pow(itUP->second.second,2);
denomSumDB += pow(itDB->second.second,2);
}
float denomSum = sqrt(denomSumUP) * sqrt(denomSumDB);
float results = numerSum / denomSum;
return results;
}