本文整理汇总了C++中Analyser::getHSHistogram方法的典型用法代码示例。如果您正苦于以下问题:C++ Analyser::getHSHistogram方法的具体用法?C++ Analyser::getHSHistogram怎么用?C++ Analyser::getHSHistogram使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analyser
的用法示例。
在下文中一共展示了Analyser::getHSHistogram方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processImage
Leaf processImage(string currentImgName) {
Leaf newLeaf;
newLeaf.path = "";
newLeaf.filename = "";
newLeaf.filenameProcessed = "";
newLeaf.filenameSegmented = "";
newLeaf.isSick = false;
newLeaf.sicknessLevel = 0.0;
// on sépare le chemin et le nom de l'image
string tmp = string(currentImgName);
while (tmp[tmp.length()-1] != '/') {
newLeaf.filename = tmp[tmp.length()-1] + newLeaf.filename;
//tmp.pop_back();
tmp = tmp.substr(0,tmp.length()-1);
}
newLeaf.path = tmp;
// on supprime l'extension de l'image
tmp = string(newLeaf.filename);
while (tmp[tmp.length()-1] != '.')
tmp = tmp.substr(0,tmp.length()-1);
//tmp.pop_back();
//tmp.pop_back();
tmp = tmp.substr(0,tmp.length()-1);
// on crée les noms des nouvelles images
newLeaf.filenameProcessed = tmp + "_processed.jpg";
newLeaf.filenameSegmented = tmp + "_segmented.jpg";
cout << "Loading: " << newLeaf.path << newLeaf.filename << endl;
string dataPath = "../data/";
Analyser analyser;
string histogramName = dataPath + "leafsample.png";
Mat leafHisto = analyser.getHSHistogram(histogramName);
histogramName = dataPath + "injuredsample.png";
Mat injuriesHisto = analyser.getHSHistogram(histogramName);
cout << "loaded histogram" << endl;
Mat currentImg = imread(currentImgName, CV_LOAD_IMAGE_UNCHANGED);
if (currentImg.empty()) //check whether the image is loaded or not
{
cout << "Error : Image cannot be loaded..!!" << endl;
//system("pause"); //wait for a key press
return newLeaf;
}
Mat origImg = currentImg;
// La comparaison d'histogramme nous permet de faire un masque de probabilité
Mat leafMask;
analyser.compareToHistogram(origImg, leafHisto, leafMask);
// Segmentation de la feuille
Mat leafImg;
analyser.segmentLeaf(origImg, leafMask, leafImg);
// La détection de contours nous permet de faire ressortir les irrégularités
Mat detailedEdges, coarseEdges;
analyser.detectEdges(leafImg, detailedEdges, coarseEdges);
Mat leafIrregularities;
analyser.detectIrregularities(detailedEdges, coarseEdges, leafIrregularities);
float irregularityScore = analyser.computeIrregularityScore(leafIrregularities, leafMask);
// La comparaison d'histogramme nous permet de faire un masque de probabilité
Mat injuriesMask;
analyser.compareToHistogram(leafImg, injuriesHisto, injuriesMask);
// Segmentation de la feuille
Mat injuriesImg;
analyser.segmentLeaf(origImg, injuriesMask, injuriesImg);
float injuriesScore = analyser.computeInjuriesScore(injuriesImg, injuriesMask);
float illnessScore = irregularityScore * injuriesScore * 100;
cout << "injuriesScore: " << injuriesScore << endl;
cout << "irregularityScore: " << irregularityScore << endl;
cout << "score: " << illnessScore << endl;
if (illnessScore > 0.5 && injuriesScore > 0.1) {
cout << "Leaf is sick " << injuriesScore*100 << "%." << endl;
newLeaf.isSick = true;
newLeaf.sicknessLevel = injuriesScore*100;
} else {
cout << "Leaf is not sick." << endl;
}
Mat finalImg = analyser.createInfoImage(leafImg, leafMask, leafIrregularities);
//outfilename = outfileprefix + "_processed.jpg";
imwrite(newLeaf.path + newLeaf.filenameProcessed, finalImg);
//.........这里部分代码省略.........