$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
influence_zone_functor.hh
1 // Copyright (C) 2008, 2009 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 MLN_TRANSFORM_INTERNAL_INFLUENCE_ZONE_FUNCTOR_HH
27 # define MLN_TRANSFORM_INTERNAL_INFLUENCE_ZONE_FUNCTOR_HH
28 
32 
33 # include <mln/core/routine/duplicate.hh>
34 
35 
36 
37 namespace mln
38 {
39 
40  namespace transform
41  {
42 
43  namespace internal
44  {
45 
46  template <typename I>
48  {
49  typedef mln_value(I) V;
50  typedef mln_psite(I) P;
51 
53  influence_zone_functor(const V& background_value);
54 
55  mln_concrete(I) output;
56 
57  void init(const I& input);
58  bool inqueue_p_wrt_input_p(const V& input_p);
59  bool inqueue_p_wrt_input_n(const V& input_n);
60  void init_p(const P&);
61  void process(const P& p, const P& n);
62 
63  void init_(const I& input);
64  bool inqueue_p_wrt_input_p_(const V& input_p);
65  bool inqueue_p_wrt_input_n_(const V& input_n);
66  void init_p_(unsigned);
67  void process_(unsigned p, unsigned n);
68 
70  };
71 
72 
73 # ifndef MLN_INCLUDE_ONLY
74 
75 
76  template <typename I>
77  inline
79  {
80  background_value_ = literal::zero;
81  }
82 
83 
84  template <typename I>
85  inline
86  influence_zone_functor<I>::influence_zone_functor(const V& background_value)
87  {
88  background_value_ = background_value;
89  }
90 
91 
92  // Generic implementation.
93 
94  template <typename I>
95  inline
96  void
97  influence_zone_functor<I>::init(const I& input)
98  {
99  output = duplicate(input);
100  }
101 
102  template <typename I>
103  inline
104  bool
106  {
107  return input_p != background_value_;
108  }
109 
110  template <typename I>
111  inline
112  bool
114  {
115  return input_n == background_value_;
116  }
117 
118  template <typename I>
119  inline
120  void
122  {
123  }
124 
125  template <typename I>
126  inline
127  void influence_zone_functor<I>::process(const P& p, const P& n)
128  {
129  output(n) = output(p);
130  }
131 
132 
133 
134  // Fastest implementation.
135 
136  template <typename I>
137  inline
138  void
139  influence_zone_functor<I>::init_(const I& input)
140  {
141  output = duplicate(input);
142  }
143 
144  template <typename I>
145  inline
146  bool
148  {
149  return input_p != background_value_;
150  }
151 
152  template <typename I>
153  inline
154  bool
156  {
157  return input_n == background_value_;
158  }
159 
160  template <typename I>
161  inline
162  void
164  {
165  }
166 
167  template <typename I>
168  inline
169  void influence_zone_functor<I>::process_(unsigned p, unsigned n)
170  {
171  output.element(n) = output.element(p);
172  }
173 
174 
175 # endif // ! MLN_INCLUDE_ONLY
176 
177  } // end of namespace mln::transform::internal
178 
179  } // end of namespace mln::transform
180 
181 } // end of namespace mln
182 
183 
184 #endif // ! MLN_TRANSFORM_INTERNAL_INFLUENCE_ZONE_FUNCTOR_HH