-
Notifications
You must be signed in to change notification settings - Fork 13
/
README.txt
162 lines (117 loc) · 5.2 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
This is a simple Cython wrapper around the MAXFLOW library from Boykov
and Kolmogorov. Their original README and License information are
included below. Cython wrapper by Thouis (Ray) Jones.
Installation
============
Requirements
------------
- cython (version 0.19.1 works, version 0.16 not)
- numpy
- matplotlib (only for example test.py)
Installation with Pip
---------------------
$ pip install git+<repository clone url from the github sidebar>#egg=pymaxflow
Manual Installation
-------------------
- download the package
$ python setup.py build_ext --inplace
install the package with pip (can be uninstalled)
$ pip install .
or install the package with distutils
$ python setup.py install
Test the Package
----------------
$ python test.py someimage.png
... figure with input image segmentation should pop up
###################################################################
# #
# MAXFLOW - software for computing mincut/maxflow in a graph #
# Version 3.01 #
# http://www.cs.ucl.ac.uk/staff/V.Kolmogorov/software.html #
# #
# Yuri Boykov ([email protected]) #
# Vladimir Kolmogorov ([email protected]) #
# 2001-2006 #
# #
###################################################################
1. Introduction.
This software library implements the maxflow algorithm described in
"An Experimental Comparison of Min-Cut/Max-Flow Algorithms for Energy Minimization in Vision."
Yuri Boykov and Vladimir Kolmogorov.
In IEEE Transactions on Pattern Analysis and Machine Intelligence (PAMI),
September 2004
This algorithm was developed by Yuri Boykov and Vladimir Kolmogorov
at Siemens Corporate Research. To make it available for public use,
it was later reimplemented by Vladimir Kolmogorov based on open publications.
If you use this software for research purposes, you should cite
the aforementioned paper in any resulting publication.
----------------------------------------------------------------------
REUSING TREES:
Starting with version 3.0, there is a also an option of reusing search
trees from one maxflow computation to the next, as described in
"Efficiently Solving Dynamic Markov Random Fields Using Graph Cuts."
Pushmeet Kohli and Philip H.S. Torr
International Conference on Computer Vision (ICCV), 2005
If you use this option, you should cite
the aforementioned paper in any resulting publication.
Tested under windows, Visual C++ 6.0 compiler and unix (SunOS 5.8
and RedHat Linux 7.0, GNU c++ compiler).
##################################################################
2. License & disclaimer.
Copyright 2001-2006 Vladimir Kolmogorov ([email protected]), Yuri Boykov ([email protected]).
This software can be used for research purposes only.
If you require another license, you may consider using version 2.21
(which implements exactly the same algorithm, but does not have the option of reusing search trees).
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##################################################################
3. Example usage.
This section shows how to use the library to compute
a minimum cut on the following graph:
SOURCE
/ \
1/ \2
/ 3 \
node0 -----> node1
| <----- |
| 4 |
\ /
5\ /6
\ /
SINK
///////////////////////////////////////////////////
#include <stdio.h>
#include "graph.h"
int main()
{
typedef Graph<int,int,int> GraphType;
GraphType *g = new GraphType(/*estimated # of nodes*/ 2, /*estimated # of edges*/ 1);
g -> add_node();
g -> add_node();
g -> add_tweights( 0, /* capacities */ 1, 5 );
g -> add_tweights( 1, /* capacities */ 2, 6 );
g -> add_edge( 0, 1, /* capacities */ 3, 4 );
int flow = g -> maxflow();
printf("Flow = %d\n", flow);
printf("Minimum cut:\n");
if (g->what_segment(0) == GraphType::SOURCE)
printf("node0 is in the SOURCE set\n");
else
printf("node0 is in the SINK set\n");
if (g->what_segment(1) == GraphType::SOURCE)
printf("node1 is in the SOURCE set\n");
else
printf("node1 is in the SINK set\n");
delete g;
return 0;
}
///////////////////////////////////////////////////