-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a graphcut directory. Compiling but main function not recognized
- Loading branch information
Camille
authored and
Camille
committed
Oct 27, 2011
1 parent
909e269
commit 6878c66
Showing
17 changed files
with
2,054 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
include_directories (${PROJECT_SOURCE_DIR}/graphcuts) | ||
|
||
add_library(graphcuts | ||
maxflow.cpp) | ||
|
||
set (CMAKE_CXX_FLAGS "-fpic -g -DUNIXIO") | ||
target_link_libraries(graphcuts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/* | ||
Copyright ESIEE (2009) | ||
m.couprie@esiee.fr | ||
This software is an image processing library whose purpose is to be | ||
used primarily for research and teaching. | ||
This software is governed by the CeCILL license under French law and | ||
abiding by the rules of distribution of free software. You can use, | ||
modify and/ or redistribute the software under the terms of the CeCILL | ||
license as circulated by CEA, CNRS and INRIA at the following URL | ||
"http://www.cecill.info". | ||
As a counterpart to the access to the source code and rights to copy, | ||
modify and redistribute granted by the license, users are provided only | ||
with a limited warranty and the software's author, the holder of the | ||
economic rights, and the successive licensors have only limited | ||
liability. | ||
In this respect, the user's attention is drawn to the risks associated | ||
with loading, using, modifying and/or developing or reproducing the | ||
software by the user in light of its specific status of free software, | ||
that may mean that it is complicated to manipulate, and that also | ||
therefore means that it is reserved for developers and experienced | ||
professionals having in-depth computer knowledge. Users are therefore | ||
encouraged to load and test the software's suitability as regards their | ||
requirements in conditions enabling the security of their systems and/or | ||
data to be ensured and, more generally, to use and operate it in the | ||
same conditions as regards security. | ||
The fact that you are presently reading this means that you have had | ||
knowledge of the CeCILL license and that you accept its terms. | ||
*/ | ||
|
||
/* ============================================================================== */ | ||
/* | ||
Structure de donnees pour la construction de l'arbre des composantes. | ||
Les sommets de cet arbre representent les composantes des coupes de F, | ||
a l'exception de celles qui sont egales a une composante d'un niveau inferieur. | ||
Il y a donc moins de N sommets (N = nombre de pixels) et de N-1 arcs. | ||
Une composante (sommet) est representee par une structure ctreenode. | ||
+ | ||
arbre des composantes d'un graphe d'adjacence valué | ||
+ | ||
arbre de fusion d'un graphe d'adjacence valué | ||
+ | ||
un arbre de saillance | ||
*/ | ||
/* ============================================================================== */ | ||
#ifndef _JCTREESTRUCT_ | ||
#define _JCTREESTRUCT_ | ||
|
||
typedef struct JCsoncell | ||
{ | ||
int32_t son; | ||
struct JCsoncell *next; | ||
} JCsoncell; | ||
|
||
typedef struct | ||
{ | ||
uint8_t data; // node's level | ||
int32_t father; // value -1 indicates the root | ||
int32_t nbsons; // value -1 indicates a deleted node | ||
int32_t max, min; | ||
JCsoncell *sonlist; | ||
JCsoncell *lastson; | ||
} JCctreenode; | ||
|
||
typedef struct | ||
{ | ||
int32_t nbnodes; | ||
int32_t nbsoncells; | ||
int32_t root; | ||
JCctreenode * tabnodes; | ||
JCsoncell * tabsoncells; | ||
uint8_t *flags; | ||
} JCctree; | ||
|
||
typedef struct | ||
{ | ||
JCctree *CT; | ||
int32_t *mergeEdge; | ||
} mtree; | ||
|
||
// Structure de Graphe binaire | ||
|
||
typedef struct BasicCell { | ||
// index du sommet extremite de l'arete | ||
uint32_t vertex; | ||
// index de l'arete | ||
uint32_t edge; | ||
struct BasicCell * next; | ||
} BasicCell; | ||
|
||
typedef BasicCell * PBasicCell; | ||
|
||
typedef struct GrapheBasic { | ||
/* informations globales */ | ||
//! nombre de sommets | ||
int32_t nsom; | ||
//! nombre maximum d'arcs | ||
int32_t nmaxarc; | ||
//! nombre d'arcs | ||
int32_t narc; // Ah les hauts fonctionnaires !! | ||
/* representation par listes chainees de successeurs (application gamma) */ | ||
//! tableau des cellules en réserve | ||
PBasicCell reserve; | ||
//! liste des cellules libres gérée en pile lifo | ||
PBasicCell libre; | ||
//! tableau des listes de successeurs indexé par les sommets | ||
PBasicCell *gamma; | ||
} GrapheBasic; | ||
|
||
|
||
// Graphe d'adjacence (graphes values contenant de l'information sur les sommets) | ||
typedef struct RAG{ | ||
GrapheBasic *g; // la structure binaire | ||
uint8_t *F; // valuation des aretes | ||
uint8_t *profondeur; // profondeur des regions | ||
uint32_t *surface; // | ||
uint32_t *altitude; // | ||
uint32_t *tete; // representation du graphe | ||
uint32_t *queue; // par liste d'aretes | ||
} RAG; | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
################################################################### | ||
# # | ||
# MAXFLOW - software for computing mincut/maxflow in a graph # | ||
# Version 3.0 # | ||
# http://www.cs.adastral.ucl.ac.uk/~vnk/software.html # | ||
# # | ||
# Yuri Boykov (yuri@csd.uwo.ca) # | ||
# Vladimir Kolmogorov (vnk@adastral.ucl.ac.uk) # | ||
# 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 Vladimir Kolmogorov (vnk@adastral.ucl.ac.uk), Yuri Boykov (yuri@csd.uwo.ca). | ||
|
||
This software can be used for research purposes only. | ||
|
||
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; | ||
} | ||
|
||
|
||
/////////////////////////////////////////////////// |
Oops, something went wrong.