-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpath.h
147 lines (113 loc) · 4.37 KB
/
path.h
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
/*
Copyright 2015 Julien Mille
This file is part of CombinationOfPiecewiseGeodesicPaths.
CombinationOfPiecewiseGeodesicPaths is free software: you can redistribute
it and/or modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
CombinationOfPiecewiseGeodesicPaths is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
General Public License for more details.
You should have received a copy of the GNU General Public License,
and a copy of the GNU Lesser General Public License, along with
CombinationOfPiecewiseGeodesicPaths. If not, see <http://www.gnu.org/licenses/>.
*/
/*
path.h
Header file of library which implements the algorithm combining
piecewise-geodesic paths to build closed contours, described in
[MBC15] J. Mille, S. Bougleux and L. Cohen. Combination of piecewise-geodesic
paths for interactive segmentation. International Journal of Computer
Vision, 112(1):1-22, 2015.
All equation, section and algorithm numbers in the comments refer to this paper
or in the supplemental document
Preprint versions of the paper and the supplemental document may be found at
http://liris.cnrs.fr/~jmille/doc/ijcv15temp.pdf
http://liris.cnrs.fr/~jmille/doc/ijcv15supp.pdf
If you use this code for research purposes, please cite the aforementioned paper
in any resulting publication.
*/
#ifndef _PATH_H_
#define _PATH_H_
#include <list>
#include "couple.h"
#include "image2d.h"
#include "arraynd.h"
using namespace std;
class CIntegerPath2D;
class CRealPath2D;
class CIntegerPath2D : public list<CCouple<int> >
{
friend class CRealPath2D;
// Member variables
public:
CImage2DByteRGBPixel rgbVertices, rgbEdges;
bool bDisplayVertices, bDisplayEdges;
float fSortingValue;
// Member functions
public:
CIntegerPath2D()
{
rgbVertices.Set(0,255,0);
rgbEdges.Set(0,0,0);
bDisplayVertices = true;
bDisplayEdges = true;
}
CIntegerPath2D(const CRealPath2D &);
// CIntegerPath2D is used to implement the discretized 4-connected admissible paths
// Before searching combination of admissible paths, we sort them in admissible
// sets with respect to some value (exteriority). We need to overload comparison
// operators to allow the STL sort() funtion
bool operator <(const CIntegerPath2D &path) const {
return fSortingValue<path.fSortingValue;
}
bool operator >(const CIntegerPath2D &path) const {
return fSortingValue>path.fSortingValue;
}
float GetLength() const;
// Compute area with discrete Green's theorem (should be a digital 4-connected closed curve)
float GetArea4connected() const;
void SetDigitalLineSegment4connected(const CCouple<int> &, const CCouple<int> &);
void AddDigitalPath4connected(const CIntegerPath2D &);
void DrawInImage(CImage2D &, int) const;
// Draw the path by considering points as pointels (pixel corners) instead of pixels
void DrawInImagePixelCorners(CImage2D &, int) const;
};
class CRealPath2D : public list<CCouple<float> >
{
friend class CIntegerPath2D;
// Member variables
public:
CImage2DByteRGBPixel rgbVertices, rgbEdges;
bool bDisplayVertices, bDisplayEdges;
float fSortingValue;
// Member functions
public:
CRealPath2D()
{
rgbVertices.Set(0,255,0);
rgbEdges.Set(0,0,0);
bDisplayVertices = true;
bDisplayEdges = true;
}
CRealPath2D(const CIntegerPath2D &);
// Admissible paths are implemented in curve with real point coordinates
// Before searching combination of admissible paths, we sort them in admissible
// sets with respect to some value (exteriority). We need to overload comparison
// operators to allow the STL sort() funtion
bool operator <(const CRealPath2D &path) const {
return fSortingValue<path.fSortingValue;
}
bool operator >(const CRealPath2D &path) const {
return fSortingValue>path.fSortingValue;
}
float GetLength() const;
void InitLine(const CCouple<float> &, const CCouple<float> &);
void LaplacianSmooth();
void Translate(const CCouple<float> &);
float GetSignedAreaWithLineSegment() const;
CRealPath2D Resampled(float) const;
void DrawInImage(CImage2D &, int) const;
};
#endif