本文整理汇总了C++中Labels::getShapeNum方法的典型用法代码示例。如果您正苦于以下问题:C++ Labels::getShapeNum方法的具体用法?C++ Labels::getShapeNum怎么用?C++ Labels::getShapeNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Labels
的用法示例。
在下文中一共展示了Labels::getShapeNum方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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);
}
}
}
示例3: upLabels
//.........这里部分代码省略.........
}
for(int shapeShift2=-1; shapeShift2<ruleSize2; shapeShift2++) {
try {
vector<vector<vector<Islands> > > islandVec4 = islandVec3;
bool flag2 = false;
String newShape2 = "NONE";
if(shapeShift2>=0) {
newShape2 = ShapeMatch::shiftingRules.at(shapeNum2).at(shapeShift2);
int newShapeIdx2 = shapematch.getShapeIndex(newShape2);
flag2 = shapematch.shape_translation(islandVec4,shapeNum2,newShapeIdx2,1);
}
if((shapeShift1==-1 && shapeShift2==-1) || (flag1==true || flag2==true)) {
this->sortIslandsByArea(islandVec4);
upLabels = Labels(islandVec4,upTotalArea,upSS.name());
upLabelsFilled = upLabels;
dbLabelsFilled = dbLabels;
this->fillMissingLabels(upLabelsFilled,dbLabelsFilled);
float tr1_score = this->tr1(upLabelsFilled,dbLabelsFilled);
tr1_score = shadematch.applyShiftPenalty(upSS,tr1_score,shadeShift);
String nStr = "n"+toString(n)+"_shd"+toString(shadeShift)+"_shp"+toString(shapeShift1)+toString(shapeShift2);
ShadeShapeRelation ssrUP;
ssrUP.spatial_relation(upSS,upLabelsFilled,islandVec4,1,newNameUP);
ShadeShapeRelation ssrDB;
ssrDB.spatial_relation(dbSS,dbLabelsFilled,this->dbIslandVec,1,newNameDB);
vector<float> tr2_scores = this->tr2(ssrUP,upLabelsFilled,ssrDB,dbLabelsFilled,nStr);
float results = tr1_score * tr2_scores.at(0);
//printf("%s\n",nStr.c_str());
//printf("TR1: %f x TR2: %f = %f\n",tr1_score,tr2_scores.at(0),results);
String labelFilename = upLabelsFilled.name()+"_"+dbLabelsFilled.name()+"_labels_"+nStr;
Labels::writeCompareLabels(labelFilename,upLabelsFilled,dbLabelsFilled,tr1_score,1);
if(results>maxResults) {
maxResults = results;
finalTR1 = tr1_score;
finalTR2_match = tr2_scores.at(0);
finalTR2_mismatch = tr2_scores.at(1);
largestLabelsUP = upLabelsFilled;
largestLabelsDB = dbLabelsFilled;
largestIslandVec = islandVec4;
maxMatchImg = largestImg;
maxNStr = nStr; //use for labeling image
}
///// Debug Print /////
if(this->debugMode>=2) {
printf("n: %d\n", n);
printf("ShadeShift: %s, ",shadematch.SHIFT()[shadeShift].c_str());
printf("CurrShape1: %s, ",shapematch.getShapeName(shapeNum1).c_str());
printf("NewShape1: %s\n",newShape1.c_str());
printf("ShadeShift: %s, ",shadematch.SHIFT()[shadeShift].c_str());
printf("CurrShape2: %s, ",shapematch.getShapeName(shapeNum2).c_str());
printf("NewShape2: %s\n",newShape2.c_str());
printf("Flag1: %d, Flag2: %d\n",flag1,flag2);
printf("TR1: %f\n",tr1_score);
printf("TR2: %f\n",tr2_scores.at(0));
printf("Result: %f\n",results);
Labels::printCompareLabels(upLabelsFilled,dbLabelsFilled,1);
cout << "-------------------------" << endl;
}
///// End Debug Print /////
}// end if flag1 || flag2
} catch (const std::out_of_range &oor) {
printf("ShapeShift1: %d\n",shapeShift1);
printf("ShapeShift2: %d\n",shapeShift2);
printf("CurrShape1: %s\n",shapematch.getShapeName(shapeNum1).c_str());
printf("CurrShape2: %s\n",shapematch.getShapeName(shapeNum2).c_str());
printf("NewShape1: %s\n",newShape1.c_str());
exit(1);
}
}// end for shapeShift2
}// end for shapeShift1
}// end if shifted condition
}// end shadeShift
}// end n
/*** Shape STT counter ***/
auto largestUpMap = largestLabelsUP.getMap();
for(auto it=largestUpMap.begin(); it!=largestUpMap.end(); it++) {
if(largestLabelsUP.isShapeShifted(it->first)) {
int prevShape = largestLabelsUP.getPrevShapeNum(it->first);
int currShape = largestLabelsUP.getShapeNum(it->first);
this->shapeTranslateCount.at(prevShape).at(currShape)=1;
}
}
/*****************************/
if(maxResults>0) {
String labelFilename = largestLabelsUP.name()+"_"+largestLabelsDB.name()+"_tr1_max_match_labels";
Labels::writeCompareLabels(labelFilename,largestLabelsUP,largestLabelsDB,-1,1);
imwrite(newNameUP+"_max_match_image_"+maxNStr+".png",maxMatchImg);
upSS.getImageData().writePrevSize(newNameUP+"_max_match_image_"+maxNStr);
this->esgPS_Map.at(maxNStr).writePrintStream(newNameUP+"_ESG_"+maxNStr+".txt");
this->entropyPS_Map.at(maxNStr).writePrintStream(newNameUP+"_entropy_output_"+maxNStr+".txt");
this->mismatchEntropyPS_Map.at(maxNStr).writePrintStream(newNameUP+"_mismatch_entropy_output_"+maxNStr+".txt");
this->noEntropyPS_Map.at(maxNStr).writePrintStream(newNameUP+"_no_entropy_"+maxNStr+".txt");
}
vector<float> vec = {maxResults,finalTR1,finalTR2_match,finalTR2_mismatch};
resultVec.push_back(vec);
return *max_element(resultVec.begin(),resultVec.end());
}