$extrastylesheet
Olena
User documentation 2.1
An Image Processing Platform
Milena
Getting started
API Reference Manual
All Classes
Examples
Demos
Publications
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
image2d-skel.hh
1
// Copyright (C) 2010, 2011 EPITA Research and Development Laboratory (LRDE)
2
//
3
// This file is part of Olena.
4
//
5
// Olena is free software: you can redistribute it and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, version 2 of the License.
8
//
9
// Olena is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
// General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
16
//
17
// As a special exception, you may use this file as part of a free
18
// software project without restriction. Specifically, if other files
19
// instantiate templates or use macros or inline functions from this
20
// file, or you compile this file and link it with other files to produce
21
// an executable, this file does not by itself cause the resulting
22
// executable to be covered by the GNU General Public License. This
23
// exception does not however invalidate any other reasons why the
24
// executable file might be covered by the GNU General Public License.
25
26
#ifndef APPS_MORPHERS_IMAGE2D_SKEL_HH
27
# define APPS_MORPHERS_IMAGE2D_SKEL_HH
28
32
33
/* FIXME: Remove this file as soon as patches from the mesh-segm-skel
34
branch have been merged into the current branch. */
35
36
# include <mln/topo/is_simple_2d.hh>
37
38
46
template
<
typename
I,
typename
N>
47
class
is_simple_2d
:
public
mln::Function_v2b
< is_simple_2d<I, N> >,
48
private
mln::topo::is_simple_2d_t
<N>
49
{
50
public
:
51
typedef
mln::topo::is_simple_2d_t<N>
super
;
52
54
typedef
bool
result
;
55
59
is_simple_2d
(
const
mln::Neighborhood<N>
& nbh_fg)
60
:
super
(mln::exact(nbh_fg)),
61
ima_(0)
62
{
63
}
64
69
is_simple_2d
(
const
mln::Neighborhood<N>
& nbh_fg,
70
const
mln::Image<I>
& ima)
71
:
super
(mln::exact(nbh_fg)),
72
ima_(mln::exact(&ima))
73
{
74
}
75
77
void
set_image
(
const
mln::Image<I>
& ima)
78
{
79
ima_ =
mln::exact
(&ima);
80
}
81
83
bool
operator()
(
const
mln_psite(I)& p)
const
84
{
85
return
this->
check
(*ima_, p);
86
}
87
88
private
:
90
const
I* ima_;
91
};
92
93
94
template
<
typename
I>
95
void
96
detach(
const
mln_psite(I)& p,
mln::Image<I>
& ima)
97
{
98
mln::exact
(ima)(p) =
false
;
99
}
100
101
102
template
<
typename
I,
typename
N>
103
struct
is_not_end_point
:
public
mln::Function_v2b
< is_not_end_point<I, N> >
104
{
109
is_not_end_point
(
const
mln::Neighborhood<N>
& nbh,
110
const
mln::Image<I>
& ima)
111
: nbh_(mln::exact(nbh)),
112
ima_(mln::exact(ima))
113
{
114
}
115
116
// Is \a p not a end point?
117
bool
operator()
(
const
mln_psite(I)& p)
const
118
{
119
// Number of foreground neighbors pixels.
120
unsigned
nneighbs = 0;
121
mln_niter(N) n(nbh_, p);
122
for_all(n)
123
if
(ima_.has(n) && ima_(n))
124
++nneighbs;
125
return
nneighbs != 1;
126
}
127
128
private
:
130
const
N& nbh_;
132
const
I& ima_;
133
};
134
135
#endif // ! APPS_MORPHERS_IMAGE2D_SKEL_HH
apps
morphers
image2d-skel.hh
Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)