├── .gitignore
├── BasicImageSegmentation.sln
├── BasicImageSegmentation
├── 1_11_s.bmp
├── BasicImageSegmentation.cpp
├── BasicImageSegmentation.vcxproj
├── BasicImageSegmentation.vcxproj.filters
├── ConfigReader.cpp
├── ConfigReader.h
├── EfficientGraphBased
│ ├── ReadMe.md
│ ├── disjoint-set.h
│ ├── segment-graph.h
│ ├── segment-image.cpp
│ └── segment-image.h
├── GrabCutSegmentor.cpp
├── GrabCutSegmentor.h
├── GraphBasedSegmentor.cpp
├── GraphBasedSegmentor.h
├── MeanShift
│ ├── Example.cpp
│ ├── RAList.cpp
│ ├── RAList.h
│ ├── ReadMe.md
│ ├── ms.cpp
│ ├── ms.h
│ ├── msImageProcessor.cpp
│ ├── msImageProcessor.h
│ ├── msSys.cpp
│ ├── msSys.h
│ ├── rlist.cpp
│ ├── rlist.h
│ └── tdef.h
├── MeanShiftSegmentor.cpp
├── MeanShiftSegmentor.h
├── OneCutSegmentor.cpp
├── OneCutSegmentor.h
├── SEEDS
│ ├── README.txt
│ ├── ReadMe.md
│ ├── seeds2.cpp
│ └── seeds2.h
├── SEEDSSegmentor.cpp
├── SEEDSSegmentor.h
├── SLIC
│ ├── README.md
│ ├── SLIC.cpp
│ ├── SLIC.h
│ └── SLICO.exe
├── SLICSegmentor.cpp
├── SLICSegmentor.h
├── Timer.h
├── config.ini
├── config_example.ini
├── lena.jpg
├── lena_big.jpg
├── multi-labelGraphCut
│ ├── GCoptimization.cpp
│ ├── GCoptimization.h
│ ├── LinkedBlockList.cpp
│ ├── LinkedBlockList.h
│ ├── ReadMe.md
│ ├── block.h
│ ├── energy.h
│ ├── graph.cpp
│ ├── graph.h
│ └── maxflow.cpp
├── segmentor.cpp
└── segmentor.h
├── LICENSE
├── OpenCV_248_x86.props
├── OpenCV_248d_x86.props
├── README.md
└── Release
├── 1_11_s.bmp
├── BasicImageSegmentation.exe
├── config.ini
├── lena.jpg
├── lena_big.jpg
├── opencv_core248.dll
├── opencv_highgui248.dll
└── opencv_imgproc248.dll
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .classpath
16 | .settings/
17 | .loadpath
18 | .class
19 |
20 | # External tool builders
21 | .externalToolBuilders/
22 |
23 | # Locally stored "Eclipse launch configurations"
24 | *.launch
25 |
26 | # CDT-specific
27 | .cproject
28 |
29 | # PDT-specific
30 | .buildpath
31 |
32 |
33 | #################
34 | ## Visual Studio
35 | #################
36 |
37 | ## Ignore Visual Studio temporary files, build results, and
38 | ## files generated by popular Visual Studio add-ons.
39 |
40 | # User-specific files
41 | *.suo
42 | *.user
43 | *.sln.docstates
44 |
45 | # Build results
46 |
47 | */[Dd]ebug/
48 | */[Rr]elease/
49 | x64/
50 | build/
51 | [Bb]in/
52 | [Oo]bj/
53 |
54 | # MSTest test Results
55 | [Tt]est[Rr]esult*/
56 | [Bb]uild[Ll]og.*
57 |
58 | *_i.c
59 | *_p.c
60 | *.ilk
61 | *.meta
62 | *.obj
63 | *.pch
64 | *.pdb
65 | *.pgc
66 | *.pgd
67 | *.rsp
68 | *.sbr
69 | *.tlb
70 | *.tli
71 | *.tlh
72 | *.tmp
73 | *.tmp_proj
74 | *.log
75 | *.vspscc
76 | *.vssscc
77 | .builds
78 | *.pidb
79 | *.log
80 | *.scc
81 |
82 | # Visual C++ cache files
83 | ipch/
84 | *.aps
85 | *.ncb
86 | *.opensdf
87 | *.sdf
88 | *.cachefile
89 |
90 | # Visual Studio profiler
91 | *.psess
92 | *.vsp
93 | *.vspx
94 |
95 | # Guidance Automation Toolkit
96 | *.gpState
97 |
98 | # ReSharper is a .NET coding add-in
99 | _ReSharper*/
100 | *.[Rr]e[Ss]harper
101 |
102 | # TeamCity is a build add-in
103 | _TeamCity*
104 |
105 | # DotCover is a Code Coverage Tool
106 | *.dotCover
107 |
108 | # NCrunch
109 | *.ncrunch*
110 | .*crunch*.local.xml
111 |
112 | # Installshield output folder
113 | [Ee]xpress/
114 |
115 | # DocProject is a documentation generator add-in
116 | DocProject/buildhelp/
117 | DocProject/Help/*.HxT
118 | DocProject/Help/*.HxC
119 | DocProject/Help/*.hhc
120 | DocProject/Help/*.hhk
121 | DocProject/Help/*.hhp
122 | DocProject/Help/Html2
123 | DocProject/Help/html
124 |
125 | # Click-Once directory
126 | publish/
127 |
128 | # Publish Web Output
129 | *.Publish.xml
130 | *.pubxml
131 |
132 | # NuGet Packages Directory
133 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
134 | #packages/
135 |
136 | # Windows Azure Build Output
137 | csx
138 | *.build.csdef
139 |
140 | # Windows Store app package directory
141 | AppPackages/
142 |
143 | # Others
144 | sql/
145 | *.Cache
146 | ClientBin/
147 | [Ss]tyle[Cc]op.*
148 | ~$*
149 | *~
150 | *.dbmdl
151 | *.[Pp]ublish.xml
152 | *.pfx
153 | *.publishsettings
154 |
155 | # RIA/Silverlight projects
156 | Generated_Code/
157 |
158 | # Backup & report files from converting an old project file to a newer
159 | # Visual Studio version. Backup files are not needed, because we have git ;-)
160 | _UpgradeReport_Files/
161 | Backup*/
162 | UpgradeLog*.XML
163 | UpgradeLog*.htm
164 |
165 | # SQL Server files
166 | App_Data/*.mdf
167 | App_Data/*.ldf
168 |
169 | #############
170 | ## Windows detritus
171 | #############
172 |
173 | # Windows image file caches
174 | Thumbs.db
175 | ehthumbs.db
176 |
177 | # Folder config file
178 | Desktop.ini
179 |
180 | # Recycle Bin used on file shares
181 | $RECYCLE.BIN/
182 |
183 | # Mac crap
184 | .DS_Store
185 |
186 |
187 | #############
188 | ## Python
189 | #############
190 |
191 | *.py[co]
192 |
193 | # Packages
194 | *.egg
195 | *.egg-info
196 | dist/
197 | build/
198 | eggs/
199 | parts/
200 | var/
201 | sdist/
202 | develop-eggs/
203 | .installed.cfg
204 |
205 | # Installer logs
206 | pip-log.txt
207 |
208 | # Unit test / coverage reports
209 | .coverage
210 | .tox
211 |
212 | #Translations
213 | *.mo
214 |
215 | #Mr Developer
216 | .mr.developer.cfg
217 |
--------------------------------------------------------------------------------
/BasicImageSegmentation.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BasicImageSegmentation", "BasicImageSegmentation\BasicImageSegmentation.vcxproj", "{A071A84F-7D72-4135-9F58-EDBDB2EDFD1B}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Win32 = Debug|Win32
9 | Release|Win32 = Release|Win32
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {A071A84F-7D72-4135-9F58-EDBDB2EDFD1B}.Debug|Win32.ActiveCfg = Debug|Win32
13 | {A071A84F-7D72-4135-9F58-EDBDB2EDFD1B}.Debug|Win32.Build.0 = Debug|Win32
14 | {A071A84F-7D72-4135-9F58-EDBDB2EDFD1B}.Release|Win32.ActiveCfg = Release|Win32
15 | {A071A84F-7D72-4135-9F58-EDBDB2EDFD1B}.Release|Win32.Build.0 = Release|Win32
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/BasicImageSegmentation/1_11_s.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/higherhu/BasicImageSegmentation/e1d1cece424185d8744ee67ec89c52ead8907031/BasicImageSegmentation/1_11_s.bmp
--------------------------------------------------------------------------------
/BasicImageSegmentation/BasicImageSegmentation.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/higherhu/BasicImageSegmentation/e1d1cece424185d8744ee67ec89c52ead8907031/BasicImageSegmentation/BasicImageSegmentation.cpp
--------------------------------------------------------------------------------
/BasicImageSegmentation/BasicImageSegmentation.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {A071A84F-7D72-4135-9F58-EDBDB2EDFD1B}
15 | Win32Proj
16 | BasicImageSegmentation
17 |
18 |
19 |
20 | Application
21 | true
22 | v110
23 | Unicode
24 |
25 |
26 | Application
27 | false
28 | v110
29 | true
30 | Unicode
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | true
46 |
47 |
48 | false
49 |
50 |
51 |
52 |
53 |
54 | Level3
55 | Disabled
56 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
57 |
58 |
59 | Console
60 | true
61 |
62 |
63 |
64 |
65 | Level3
66 |
67 |
68 | MaxSpeed
69 | true
70 | true
71 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
72 |
73 |
74 | Console
75 | true
76 | true
77 | true
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/BasicImageSegmentation/BasicImageSegmentation.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 | {16f699ae-df88-4e39-bcb2-00d13fa4dce3}
18 |
19 |
20 | {c3f45132-40c6-4a16-a2fb-afd18f66e347}
21 |
22 |
23 | {6cd27ad4-c0cd-4602-befe-1ded861d60c1}
24 |
25 |
26 | {b01d190c-1264-4051-9acb-0ea6ee348dd2}
27 |
28 |
29 |
30 |
31 | 源文件
32 |
33 |
34 | MeanShift
35 |
36 |
37 | MeanShift
38 |
39 |
40 | MeanShift
41 |
42 |
43 | MeanShift
44 |
45 |
46 | MeanShift
47 |
48 |
49 | EfficientGraphBased
50 |
51 |
52 | SEEDs
53 |
54 |
55 | SLIC
56 |
57 |
58 | 源文件
59 |
60 |
61 | 源文件
62 |
63 |
64 | 源文件
65 |
66 |
67 | 源文件
68 |
69 |
70 | 源文件
71 |
72 |
73 | 源文件
74 |
75 |
76 | 源文件
77 |
78 |
79 | 源文件
80 |
81 |
82 |
83 |
84 | MeanShift
85 |
86 |
87 | MeanShift
88 |
89 |
90 | MeanShift
91 |
92 |
93 | MeanShift
94 |
95 |
96 | MeanShift
97 |
98 |
99 | MeanShift
100 |
101 |
102 | EfficientGraphBased
103 |
104 |
105 | EfficientGraphBased
106 |
107 |
108 | EfficientGraphBased
109 |
110 |
111 | SEEDs
112 |
113 |
114 | SLIC
115 |
116 |
117 | 头文件
118 |
119 |
120 | 头文件
121 |
122 |
123 | 头文件
124 |
125 |
126 | 头文件
127 |
128 |
129 | 头文件
130 |
131 |
132 | 头文件
133 |
134 |
135 | 头文件
136 |
137 |
138 | 头文件
139 |
140 |
141 | 头文件
142 |
143 |
144 |
--------------------------------------------------------------------------------
/BasicImageSegmentation/ConfigReader.cpp:
--------------------------------------------------------------------------------
1 | #include "ConfigReader.h"
2 |
3 |
4 | ConfigReader::ConfigReader(void)
5 | {
6 | m_filename = "config.ini";
7 | ReadConfig();
8 | }
9 |
10 | ConfigReader::ConfigReader(const string& _name)
11 | {
12 | m_filename = _name;
13 | ReadConfig();
14 | }
15 |
16 | ConfigReader::~ConfigReader(void)
17 | {
18 | }
19 |
20 | void ConfigReader::GetSegRequire(vector& _req)
21 | {
22 | _req = segList;
23 | }
24 |
25 | void ConfigReader::ReadConfig()
26 | {
27 | ifstream conFile(m_filename, ios::in);
28 | if (!conFile)
29 | {
30 | cout<<"--Error: Failed to read config!"< args;
55 | ss<>arg) {
58 | args.push_back(arg);
59 | }
60 | req.second = args;
61 | segList.push_back(req);
62 | req.first.clear();
63 | req.second.clear();
64 | }
65 | }
66 | if (!req.first.empty() && req.second.empty())
67 | {
68 | segList.push_back(req);
69 | }
70 |
71 | conFile.close();
72 | }
73 |
74 | void ConfigReader::Trim(string & str)
75 | {
76 | if (str.empty()) {
77 | return;
78 | }
79 | int i, start_pos, end_pos;
80 | for (i = 0; i < str.size(); ++i) {
81 | if (!IsSpace(str[i])) {
82 | break;
83 | }
84 | }
85 | if (i == str.size()) {
86 | str = "";
87 | return;
88 | }
89 |
90 | start_pos = i;
91 |
92 | for (i = str.size() - 1; i >= 0; --i) {
93 | if (!IsSpace(str[i])) {
94 | break;
95 | }
96 | }
97 | end_pos = i;
98 |
99 | str = str.substr(start_pos, end_pos - start_pos + 1);
100 | }
101 |
102 | bool ConfigReader::IsSpace(char c)
103 | {
104 | if (' ' == c || '\t' == c)
105 | return true;
106 | return false;
107 | }
108 |
--------------------------------------------------------------------------------
/BasicImageSegmentation/ConfigReader.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/higherhu/BasicImageSegmentation/e1d1cece424185d8744ee67ec89c52ead8907031/BasicImageSegmentation/ConfigReader.h
--------------------------------------------------------------------------------
/BasicImageSegmentation/EfficientGraphBased/ReadMe.md:
--------------------------------------------------------------------------------
1 | Paper
2 | ======================
3 | Felzenszwalb P F, Huttenlocher D P. Efficient graph-based image segmentation[J]. International Journal of Computer Vision, 2004, 59(2): 167-181.
4 |
5 | SourceCode
6 | ======================
7 | http://cs.brown.edu/~pff/segment/
--------------------------------------------------------------------------------
/BasicImageSegmentation/EfficientGraphBased/disjoint-set.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2006 Pedro Felzenszwalb
3 |
4 | This program is free software; you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation; either version 2 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program; if not, write to the Free Software
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 | */
18 |
19 | #ifndef DISJOINT_SET
20 | #define DISJOINT_SET
21 |
22 | // disjoint-set forests using union-by-rank and path compression (sort of).
23 |
24 | typedef struct {
25 | int rank;
26 | int p;
27 | int size;
28 | } uni_elt;
29 |
30 | class universe {
31 | public:
32 | universe(int elements);
33 | ~universe();
34 | int find(int x);
35 | void join(int x, int y);
36 | int size(int x) const { return elts[x].size; }
37 | int nu_sets() const { return num; }
38 |
39 | private:
40 | uni_elt *elts;
41 | int num;
42 | };
43 |
44 | universe::universe(int elements) {
45 | elts = new uni_elt[elements];
46 | num = elements;
47 | for (int i = 0; i < elements; i++) {
48 | elts[i].rank = 0;
49 | elts[i].size = 1;
50 | elts[i].p = i;
51 | }
52 | }
53 |
54 | universe::~universe() {
55 | delete [] elts;
56 | }
57 |
58 | int universe::find(int x) {
59 | int y = x;
60 | while (y != elts[y].p)
61 | y = elts[y].p;
62 | elts[x].p = y;
63 | return y;
64 | }
65 |
66 | void universe::join(int x, int y) {
67 | if (elts[x].rank > elts[y].rank) {
68 | elts[y].p = x;
69 | elts[x].size += elts[y].size;
70 | } else {
71 | elts[x].p = y;
72 | elts[y].size += elts[x].size;
73 | if (elts[x].rank == elts[y].rank)
74 | elts[y].rank++;
75 | }
76 | num--;
77 | }
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/BasicImageSegmentation/EfficientGraphBased/segment-graph.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2006 Pedro Felzenszwalb
3 |
4 | This program is free software; you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation; either version 2 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program; if not, write to the Free Software
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 | */
18 |
19 | #ifndef SEGMENT_GRAPH
20 | #define SEGMENT_GRAPH
21 |
22 | #include
23 | #include
24 | #include "disjoint-set.h"
25 |
26 | // threshold function
27 | #define THRESHOLD(size, c) (c/size)
28 |
29 | typedef struct {
30 | float w;
31 | int a, b;
32 | } edge;
33 |
34 | bool operator<(const edge &a, const edge &b) {
35 | return a.w < b.w;
36 | }
37 |
38 | /*
39 | * Segment a graph
40 | *
41 | * Returns a disjoint-set forest representing the segmentation.
42 | *
43 | * nu_vertices: number of vertices in graph.
44 | * nu_edges: number of edges in graph
45 | * edges: array of edges.
46 | * c: constant for treshold function.
47 | */
48 | universe *segment_graph(int nu_vertices, int nu_edges, edge *edges, float c) {
49 | // sort edges by weight
50 | std::sort(edges, edges + nu_edges);
51 |
52 | // make a disjoint-set forest
53 | universe *u = new universe(nu_vertices);
54 |
55 | // init thresholds
56 | float *threshold = new float[nu_vertices];
57 | for (int i = 0; i < nu_vertices; i++)
58 | threshold[i] = THRESHOLD(1,c);
59 |
60 | // for each edge, in non-decreasing weight order...
61 | for (int i = 0; i < nu_edges; i++) {
62 | edge *pedge = &edges[i];
63 |
64 | // components conected by this edge
65 | int a = u->find(pedge->a);
66 | int b = u->find(pedge->b);
67 | if (a != b) {
68 | if ((pedge->w <= threshold[a]) &&
69 | (pedge->w <= threshold[b])) {
70 | u->join(a, b);
71 | a = u->find(a);
72 | threshold[a] = pedge->w + THRESHOLD(u->size(a), c);
73 | }
74 | }
75 | }
76 |
77 | // free up
78 | delete[] threshold;
79 | return u;
80 | }
81 |
82 | #endif
83 |
--------------------------------------------------------------------------------
/BasicImageSegmentation/EfficientGraphBased/segment-image.cpp:
--------------------------------------------------------------------------------
1 | #include "segment-graph.h"
2 | #include "segment-image.h"
3 | #include