Image Component Library (ICL)
GraphCutter.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLMath/src/ICLMath/GraphCutter.h **
10 ** Module : ICLMath **
11 ** Authors: Andre Ueckermann **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLMath/DynMatrix.h>
34 #include <ICLUtils/Point.h>
35 
36 namespace icl{
37  namespace math{
38 
40 
43 
44  public:
45 
46  typedef struct{
47  std::vector<int> subset;
48  int parent;
49  std::vector<int> children;
50  float cost;
51  }CutNode;
52 
54 
59  static float minCut(DynMatrix<float> &adjacencyMatrix, std::vector<int> &subset1, std::vector<int> &subset2);
60 
62 
66  static std::vector<std::vector<int> > thresholdCut(DynMatrix<float> &adjacencyMatrix, float threshold);
67 
69 
73  static std::vector<std::vector<int> > thresholdCut(DynMatrix<bool> &adjacencyMatrix, float threshold);
74 
76 
79  static std::vector<CutNode> hierarchicalCut(DynMatrix<float> &adjacencyMatrix);
80 
82 
85  static std::vector<CutNode> hierarchicalCut(DynMatrix<bool> &adjacencyMatrix);
86 
88 
91  static math::DynMatrix<float> calculateProbabilityMatrix(math::DynMatrix<bool> &initialMatrix, bool symmetry=true);
92 
94 
97  static std::vector<std::vector<int> > findUnconnectedSubgraphs(DynMatrix<float> &adjacencyMatrix);
98 
100 
104  static DynMatrix<float> createSubMatrix(DynMatrix<float> &adjacencyMatrix, std::vector<int> &subgraph);
105 
107 
110  static void mergeMatrix(DynMatrix<bool> &dst, DynMatrix<bool> &src);
111 
113 
117  static void weightMatrix(DynMatrix<float> &dst, DynMatrix<bool> &featureMatrix, float weight);
118 
119  private:
120  static std::vector<float> capforest(std::vector<utils::Point> &edgeList, std::vector<float> &edgeCosts, int subsetsSize);
121 
122  static float initialLambda(DynMatrix<float> &adjacencyMatrix, int &lambda_id);
123 
124  static void createEdgeList(DynMatrix<float> &adjacencyMatrix, std::vector<utils::Point> &edgeList, std::vector<float> &edgeCosts);
125 
126  static std::vector<std::vector<int> > createInitialNodes(DynMatrix<float> &adjacencyMatrix);
127 
128  static float merge(std::vector<utils::Point> &edgeList, std::vector<float> &edgeCosts, std::vector<float> &q,
129  std::vector<std::vector<int> > &subsets, float lambda_score, int j, int &lambda_id);
130  };
131 
132  } // namespace math
133 }
undocument this line if you encounter any issues!
Definition: Any.h:37
#define ICLMath_API
Definition: CompatMacros.h:173
Definition: GraphCutter.h:46
int parent
Definition: GraphCutter.h:48
float cost
Definition: GraphCutter.h:50
std::vector< int > subset
Definition: GraphCutter.h:47
std::vector< int > children
Definition: GraphCutter.h:49
class for graph cut algorithms on undirected graphs (a graph is represented by an adjacency matrix).
Definition: GraphCutter.h:42