Skip to content

Commit 47d5265

Browse files
committed
Add SaliencyCut
1 parent 4feff6b commit 47d5265

File tree

12 files changed

+69
-47
lines changed

12 files changed

+69
-47
lines changed

CmLib/CmLib.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,6 @@ using namespace std;
4545
#pragma comment( lib, cvLIB("core"))
4646
#pragma comment( lib, cvLIB("imgproc"))
4747
#pragma comment( lib, cvLIB("highgui"))
48-
#pragma comment( lib, cvLIB("features2d"))
49-
#pragma comment( lib, cvLIB("flann"))
50-
#pragma comment( lib, cvLIB("calib3d"))
51-
#pragma comment( lib, cvLIB("objdetect"))
52-
#pragma comment( lib, cvLIB("contrib"))
53-
#pragma comment( lib, cvLIB("nonfree"))
54-
#pragma comment( lib, cvLIB("legacy"))
55-
#pragma comment( lib, cvLIB("ml"))
56-
#pragma comment( lib, cvLIB("photo"))
57-
#pragma comment( lib, cvLIB("stitching"))
58-
#pragma comment( lib, cvLIB("ts"))
59-
#pragma comment( lib, cvLIB("video"))
60-
#pragma comment( lib, cvLIB("videostab"))
6148
using namespace cv;
6249

6350

@@ -117,7 +104,7 @@ using namespace cv;
117104
// Saliency detection algorithms
118105
#include "./Saliency/CmSaliencyRC.h"
119106
#include "./Saliency/CmSaliencyGC.h"
120-
//#include "./Saliency/CmSalCut.h"
107+
#include "./Saliency/CmSalCut.h"
121108
//#include "./Saliency/CmGrabCutUI.h"
122109
//
123110
//

CmLib/CmLib.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
<ClInclude Include="Illustration\CmShow.h" />
161161
<ClInclude Include="OtherAlg\CmCurveEx.h" />
162162
<ClInclude Include="OtherAlg\CmValStructVec.h" />
163+
<ClInclude Include="Saliency\CmSalCut.h" />
163164
<ClInclude Include="Saliency\CmSaliencyGC.h" />
164165
<ClInclude Include="Saliency\CmSaliencyRC.h" />
165166
<ClInclude Include="Segmentation\EfficientGraphBased\disjoint-set.h" />
@@ -196,6 +197,7 @@
196197
<ClCompile Include="Illustration\CmIllu.cpp" />
197198
<ClCompile Include="Illustration\CmShow.cpp" />
198199
<ClCompile Include="OtherAlg\CmCurveEx.cpp" />
200+
<ClCompile Include="Saliency\CmSalCut.cpp" />
199201
<ClCompile Include="Saliency\CmSaliencyGC.cpp" />
200202
<ClCompile Include="Saliency\CmSaliencyRC.cpp" />
201203
<ClCompile Include="Segmentation\EfficientGraphBased\segment-image.cpp" />

CmLib/CmLib.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@
151151
<ClInclude Include="OtherAlg\CmValStructVec.h">
152152
<Filter>OhterAlg</Filter>
153153
</ClInclude>
154+
<ClInclude Include="Saliency\CmSalCut.h">
155+
<Filter>Saliency</Filter>
156+
</ClInclude>
154157
</ItemGroup>
155158
<ItemGroup>
156159
<ClCompile Include="stdafx.cpp">
@@ -237,5 +240,8 @@
237240
<ClCompile Include="Illustration\CmIllu.cpp">
238241
<Filter>Illustration</Filter>
239242
</ClCompile>
243+
<ClCompile Include="Saliency\CmSalCut.cpp">
244+
<Filter>Saliency</Filter>
245+
</ClCompile>
240246
</ItemGroup>
241247
</Project>

CmLib/Illustration/CmEvaluation.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void CmEvaluation::Evaluate(CStr gtW, CStr &salDir, CStr &resName, vecS &des)
6060
CV_Assert(fpr[i].size() == tpr[i].size() && precision[i].size() == recall[i].size() && fpr[i].size() == precision[i].size());
6161
for (size_t t = 0; t < fpr[i].size(); t++){
6262
double fMeasure = (1+betaSqr) * precision[i][t] * recall[i][t] / (betaSqr * precision[i][t] + recall[i][t]);
63-
//avgFMeasure[i] += fMeasure/fpr[i].size(); // Doing average like this might have strange effect as in:
63+
avgFMeasure[i] += fMeasure/fpr[i].size(); // Doing average like this might have strange effect as in:
6464
maxFMeasure[i] = max(maxFMeasure[i], fMeasure);
6565
if (t > 0){
6666
areaROC[i] += (tpr[i][t] + tpr[i][t - 1]) * (fpr[i][t - 1] - fpr[i][t]) / 2.0;
@@ -182,17 +182,17 @@ double CmEvaluation::interUnionBBox(const Vec4i &box1, const Vec4i &box2) // eac
182182
return ov;
183183
}
184184

185-
void CmEvaluation::EvalueMask(CStr gtW, CStr &maskDir, CStr &gtExt, CStr &des, CStr resFile, double betaSqr, bool alertNul, CStr suffix)
185+
void CmEvaluation::EvalueMask(CStr gtW, CStr &maskDir, CStr &des, CStr resFile, double betaSqr, bool alertNul, CStr suffix)
186186
{
187187
vecS descri(1); descri[0] = des;
188-
EvalueMask(gtW, maskDir, gtExt, descri, resFile, betaSqr, alertNul, suffix);
188+
EvalueMask(gtW, maskDir, descri, resFile, betaSqr, alertNul, suffix);
189189
}
190190

191-
void CmEvaluation::EvalueMask(CStr gtW, CStr &maskDir, CStr &gtExt, vecS &des, CStr resFile, double betaSqr, bool alertNul, CStr suffix)
191+
void CmEvaluation::EvalueMask(CStr gtW, CStr &maskDir, vecS &des, CStr resFile, double betaSqr, bool alertNul, CStr suffix)
192192
{
193193
vecS namesNS;
194-
string gtDir;
195-
int imgNum = CmFile::GetNamesNoSuffix(gtW, namesNS, gtExt, gtDir);
194+
string gtDir, gtExt;
195+
int imgNum = CmFile::GetNamesNE(gtW, namesNS, gtDir, gtExt);
196196
int methodNum = (int)des.size();
197197
vecD pr(methodNum), rec(methodNum), count(methodNum), fm(methodNum);
198198
for (int i = 0; i < imgNum; i++){
@@ -230,7 +230,7 @@ void CmEvaluation::EvalueMask(CStr gtW, CStr &maskDir, CStr &gtExt, vecS &des, C
230230
CmEvaluation::PrintVector(f, pr, "PrecisionMask" + suffix);
231231
CmEvaluation::PrintVector(f, rec, "RecallMask" + suffix);
232232
CmEvaluation::PrintVector(f, fm, "FMeasureMask" + suffix);
233-
fprintf(f, "bar(%s);\ntitle('%s')\n", _S("FMeasureMask" + suffix), _S("FMeasureMask" + suffix));
233+
fprintf(f, "bar([%s]');\ntitle('%s');\ngrid on\n", _S("PrecisionMask" + suffix + "; RecallMask" + suffix + "; FMeasureMask" + suffix), _S("Segmentation" + suffix));
234234
fclose(f);
235235
}
236236

CmLib/Illustration/CmEvaluation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ struct CmEvaluation
2323
static void Evaluate(CStr gtW, CStr &salDir, CStr &resName, CStr &des) {vecS descri(1); descri[0] = des; Evaluate(gtW, salDir, resName, descri);}
2424

2525
// Plot the FMeasure bar
26-
static void EvalueMask(CStr gtW, CStr &maskDir, CStr &gtExt, vecS &des, CStr resFile, double betaSqr = 0.3, bool alertNul = false, CStr suffix = "");
27-
static void EvalueMask(CStr gtW, CStr &maskDir, CStr &gtExt, CStr &des, CStr resFile, double betaSqr = 0.3, bool alertNul = false, CStr suffix = "");
26+
static void EvalueMask(CStr gtW, CStr &maskDir, vecS &des, CStr resFile, double betaSqr = 0.3, bool alertNul = false, CStr suffix = "");
27+
static void EvalueMask(CStr gtW, CStr &maskDir, CStr &des, CStr resFile, double betaSqr = 0.3, bool alertNul = false, CStr suffix = "");
2828

2929
public: // Assistant functions
3030

CmLib/Saliency/CmSaliencyGC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ int CmSaliencyGC::Demo(CStr imgW, CStr salDir)
287287
imwrite(outName + "_GC.png", sal1f*255);
288288
}
289289
tm.Stop();
290-
printf("Speed: %g seconds = %g fps\n", tm.TimeInSeconds()/imgNum, imgNum/tm.TimeInSeconds());
290+
printf("Speed of GC method: %g seconds = %g fps\n", tm.TimeInSeconds()/imgNum, imgNum/tm.TimeInSeconds());
291291

292292
des.push_back("GC");
293293
CmEvaluation::Evaluate(imgDir + "*.png", salDir, salDir + "Eval.m", des);

CmLib/Saliency/CmSaliencyRC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void CmSaliencyRC::Get(CStr &imgNameW, CStr &salFileDir)
2323
#pragma omp parallel for
2424
for (int i = 0; i < imgNum; i++){
2525
string name = names[i] + ext;
26-
printf("Processing %d/%dth image: %-20s\r", i, imgNum, name.c_str());
26+
//printf("Processing %d/%dth image: %-20s\r", i, imgNum, name.c_str());
2727
Mat sal, img3f = imread(inDir + name);
2828
if (img3f.data == NULL){
2929
printf("Can't load image %s, in %s:%d\n", name.c_str(), __FILE__, __LINE__);

CmLib/Saliency/CmSaliencyRC.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,11 @@ struct CmSaliencyRC
7272

7373
/************************************************************************/
7474
/*[1]R. Achanta, S. Hemami, F. Estrada and S. Susstrunk, Frequency-tuned*/
75-
/* Salient Region Detection, IEEE International Conference on Computer*/
76-
/* Vision and Pattern Recognition (CVPR), 2009. */
75+
/* Salient Region Detection, IEEE CVPR, 2009. */
7776
/*[2]Y. Zhai and M. Shah. Visual attention detection in video sequences */
78-
/* using spatiotemporal cues. In ACM Multimedia, pages 815¨C824. ACM, */
79-
/* 2006. */
80-
/*[3]M.-M. Cheng, G.-X. Zhang, N. J. Mitra, X. Huang, S.-M. Hu. Global */
81-
/* Contrast based Salient Region Detection. IEEE CVPR, p. 409-416, */
82-
/* 2011 */
77+
/* using spatiotemporal cues. In ACM Multimedia 2006. */
78+
/*[3]M.-M. Cheng, N. J. Mitra, X. Huang, P.H.S. Torr S.-M. Hu. Global */
79+
/* Contrast based Salient Region Detection. IEEE PAMI, 2014. */
8380
/*[4]X. Hou and L. Zhang. Saliency detection: A spectral residual */
84-
/* approach. In IEEE Conference on Computer Vision and Pattern */
85-
/* Recognition, 2007. CVPR 2007, pages 1¨C8, 2007. */
81+
/* approach. In IEEE CVPR 2007, 2007. */
8682
/************************************************************************/

CurveExtractionHHME09/stdafx.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@
1111

1212

1313

14-
// TODO: reference additional headers your program requires here
15-
#include <Cmcode\CmLib\cmlib.h>
14+
#include "..\CmLib\cmlib.h"

Saliency/SaliencyMain.cpp

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
1-
// SaliencyICCV13.cpp : Defines the entry point for the console application.
2-
//
3-
41
#include "stdafx.h"
52

63
int main(int argc, char* argv[])
74
{
8-
CStr wkDir = "D:/Saliency/MSRA10K/";
5+
CStr wkDir = "D:/WkDir/Saliency/MSRA10K/";
6+
CStr inDir = wkDir + "Imgs/", outDir = wkDir + "Saliency/";
7+
CmFile::Copy2Dir(inDir + "*.jpg", outDir);
8+
9+
CStr srcDir = "D:/Downloads/MSRA10K_Maps_Cuts/SaliencyCut/";
10+
vecS namesNE;
11+
int imgNum = CmFile::GetNamesNE(srcDir + "*_RCC.png", namesNE);
12+
for (int i = 0; i < imgNum; i++)
13+
CmFile::Copy(srcDir + namesNE[i] + ".png", outDir + namesNE[i] + "O.png");
14+
915

1016
// Saliency detection method pretended in my ICCV 2013 paper http://mmcheng.net/effisalobj/.
11-
return CmSaliencyGC::Demo(wkDir + "Imgs/*.jpg", wkDir + "/Saliency/");
17+
//CmSaliencyGC::Demo(inDir + "*.jpg", outDir);
18+
19+
// Saliency detection method presented in PAMI 2014 (CVPR 2011) paper http://mmcheng.net/salobj/.
20+
CmSalCut::Demo(inDir + "83262*.jpg", inDir + "*.png", outDir);
21+
22+
//CmSaliencyRC::Get(inDir + "*.jpg", outDir);
1223

13-
// Saliency detection method presented in CVPR11 paper and its journal version http://mmcheng.net/salobj/.
14-
return CmSaliencyRC::Demo("D:/WkDir/Saliency/FT1000/");
24+
vecS des, desCut;
25+
des.push_back("RC"); des.push_back("GC");
26+
desCut.push_back("RCC"); desCut.push_back("RCCO");
27+
//CmEvaluation::Evaluate(inDir + "*.png", outDir, wkDir + "Results.m", des);
28+
CmEvaluation::EvalueMask(inDir + "*.png", outDir, desCut, wkDir + "CutRes.m");
1529

16-
vecS des;
17-
des.push_back("_RC");
18-
des.push_back("_HC");
19-
CmEvaluation::Evaluate(wkDir + "Imgs/*.png", wkDir + "Saliency/", wkDir + "Results.m", des);
30+
return 0;
2031
}

SpReco/SREngine.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
#pragma once
22

3+
/************************************************************************/
4+
/* Notice: this project is used to support speech recognition of my */
5+
/* ImageSpirit project. Please see the corresponding paper for more */
6+
/* details. The CORE part of ImageSpirit system will be made public */
7+
/* available soon. More resource: http://mmcheng.net/imagespirit/ */
8+
/* ImageSpirit: Verbal Guided Image Parsing. M.-M. Cheng, S. Zheng, */
9+
/* W.-Y. Lin, V. Vineet, P. Sturgess, N. Crook, N. Mitra, P. Torr, */
10+
/* ACM TOG, 2014. */
11+
/************************************************************************/
12+
313
#include <sphelper.h> // Microsoft Speech API
414

515
class SREngine

SpReco/main.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1+
/************************************************************************/
2+
/* Notice: this project is used to support speech recognition of my */
3+
/* ImageSpirit project. Please see the corresponding paper for more */
4+
/* details. The CORE part of ImageSpirit system will be made public */
5+
/* available soon. More resource: http://mmcheng.net/imagespirit/ */
6+
/* ImageSpirit: Verbal Guided Image Parsing. M.-M. Cheng, S. Zheng, */
7+
/* W.-Y. Lin, V. Vineet, P. Sturgess, N. Crook, N. Mitra, P. Torr, */
8+
/* ACM TOG, 2014. */
9+
/************************************************************************/
10+
111
#include "stdafx.h"
212
#include "SpRecoUI.h"
313

14+
415
int main(int argc, char *argv[])
516
{
617
QApplication a(argc, argv);

0 commit comments

Comments
 (0)