PlanarGC  1.0.2
 All Data Structures Functions Variables Enumerations Enumerator Friends Pages
CutGrid.h
1 /*****************************************************************************
2 * PlanarCut - software to compute MinCut / MaxFlow in a planar graph *
3 * Version 1.0 *
4 * *
5 * Copyright 2011 Eno Töppe <toeppe@in.tum.de> *
6 * Frank R. Schmidt <fschmidt@uwo.ca> *
7 ******************************************************************************
8 
9  If you use this software for research purposes, YOU MUST CITE the following
10  paper in any resulting publication:
11 
12  [1] Efficient Planar Graph Cuts with Applications in Computer Vision.
13  F. R. Schmidt, E. Töppe, D. Cremers,
14  IEEE CVPR, Miami, Florida, June 2009
15 
16 ******************************************************************************
17 
18  This software is released under the LGPL license. Details are explained
19  in the files 'COPYING' and 'COPYING.LESSER'.
20 
21 *****************************************************************************/
22 
23 #ifndef __CUTGRID_H__
24 #define __CUTGRID_H__
25 
26 #include "CutPlanar.h"
27 #include <stdio.h>
28 
29 
30 
31 class CutGrid
39 {
40  public:
41 
47  enum EDir {
52  };
53 
54  private:
55 
56  //dimensions of the grid
57  int nCols;
58  int nRows;
59 
60  //planar graph entities
61  PlanarVertex *verts;
62  PlanarEdge *edges;
63  PlanarFace *faces;
64 
65  //metrics of the planar graph
66  int nFaces;
67  int nFacesPerRow;
68  int nFacesPerCol;
69 
70  int nEdges;
71  int nHorzEdgesPerRow;
72  int nVertEdgesPerRow;
73  int nHorzEdges;
74  int nVertEdges;
75 
76  int nVerts;
77 
78  //planar cut related
79  CutPlanar pc;
80 
81  int idxSource;
82  int idxSink;
83 
84  typedef CapType (*EdgeCostFunc)(int row, int col, EDir dir);
85  EdgeCostFunc edgeCostFunc;
86 
87  static CapType edgeCostNull(int row, int col, EDir dir);
88 
89  public:
100  CutGrid(int nRows, int nCols);
104  virtual ~CutGrid();
105 
107  void setSource(int row, int col);
109  void setSink(int row, int col);
110 
112  void getSource(int &row, int &col);
114  void getSink(int &row, int &col);
115 
123  void setEdgeCostFunction(CapType (*edgeCostFunc)(int row, int col, EDir dir));
124 
130  virtual CapType edgeCost(int row, int col, EDir dir);
131 
134  double getMaxFlow();
135 
136  //returns the label of a the pixel at (x,y)
139  CutPlanar::ELabel getLabel(int row, int col);
140 
145  void getLabels(CutPlanar::ELabel *lmask);
146 };
147 
148 
149 #endif
© 2009 - 2013 by Eno Töppe, Frank R. Schmidt
generated by Doxygen