PlanarGC  1.0.2
 All Data Structures Functions Variables Enumerations Enumerator Friends Pages
CutShape.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 #include <vector>
24 #include "Planar.h"
25 
26 class CutShape
40 {
41 
42 public:
43  enum DTWMode {
52  };
53 
56  CutShape() :
57  shapeNum(0), isMatched(false),
58  numV(0), numE(0), numF(0), verts(0), edges(0), faces(0) {};
61  ~CutShape();
62 
74  void setDissimilarityMatrix(int n, double *dissimilarity, DTWMode mode=EDGE_BASED);
76  inline double getMatchingScore();
82  inline std::vector< std::pair<int,int> > getMatching(); //returns the matching interpretation of the cut
83 
84 
85 private:
86  enum edgeDirection {
87  HORIZONTAL,
88  VERTICAL,
89  DIAGONAL
90  };
91 
92  void computeMatching();
93  PlanarVertex* vertXY(int x, int y);
94  PlanarFace* faceXY(int x, int y);
95  double getEdgeWeight(int x, int y, double *dissimilarity, edgeDirection d);
96 
97  DTWMode matchingMode;
98  int shapeNum;
99  bool isMatched;
100  double matchingScore;
101  std::vector< std::pair<int,int> > matching;
102  // internal graph
103  int numV, numE, numF;
104  PlanarVertex* verts;
105  PlanarEdge* edges;
106  PlanarFace* faces;
107  PlanarVertex *source, *sink;
108  // ShapeCut specific graph related variables
109  int vertsPerRow, facesPerRow, vertRows, faceRows;
110  int hEdgesPerRow, vEdgesPerRow, dEdgesPerRow;
111 };
112 
113 /***************************************************
114  *** CutShape INLINE *******************************
115  ***************************************************/
116 inline double CutShape::getMatchingScore() {
117  if (!isMatched) computeMatching();
118  return matchingScore;
119 }
120 
121 
122 inline std::vector< std::pair<int,int> > CutShape::getMatching() {
123  if (!isMatched) computeMatching();
124  return matching;
125 }
126 
© 2009 - 2013 by Eno Töppe, Frank R. Schmidt
generated by Doxygen