$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
accu/image/init.hh
1 // Copyright (C) 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_ACCU_IMAGE_INIT_HH
27 # define MLN_ACCU_IMAGE_INIT_HH
28 
32 
33 # include <mln/core/concept/accumulator.hh>
34 # include <mln/core/concept/image.hh>
35 
36 
37 namespace mln
38 {
39 
40  namespace accu
41  {
42 
43  namespace image
44  {
45 
46  template <typename I>
47  void
48  init(Image<I>& input);
49 
50 
51 
52 # ifndef MLN_INCLUDE_ONLY
53 
54  namespace impl
55  {
56 
57  // Generic version.
58 
59  namespace generic
60  {
61 
62  template <typename I>
63  void
64  init(Image<I>& input_)
65  {
66  mln_trace("accu::impl::image::generic::init");
67 
68  mlc_is_a(mln_value(I), Accumulator)::check();
69 
70  I& input = exact(input_);
71  mln_precondition(input.is_valid());
72 
73  mln_piter(I) p(input.domain());
74  for_all(p)
75  input(p).init();
76 
77  }
78 
79  } // end of namespace mln::accu::image::impl::generic
80 
81 
82  // Fastest version.
83 
84  template <typename I>
85  void
86  init_fastest(Image<I>& input_)
87  {
88  mln_trace("accu::impl::image::init_fastest");
89 
90  mlc_is_a(mln_value(I), Accumulator)::check();
91 
92  I& input = exact(input_);
93  mln_precondition(input.is_valid());
94 
95  mln_pixter(I) px(input);
96  for_all(px)
97  px.val().init();
98 
99  }
100 
101  } // end of namespace mln::accu::image::impl
102 
103 
104 
105  // Dispatch.
106 
107  namespace internal
108  {
109 
110  template <typename I>
111  void
112  init_dispatch(trait::image::speed::any,
113  Image<I>& input)
114  {
115  impl::generic::init(input);
116  }
117 
118  template <typename I>
119  void
120  init_dispatch(trait::image::speed::fastest,
121  Image<I>& input)
122  {
123  impl::init_fastest(input);
124  }
125 
126  template <typename I>
127  void
128  init_dispatch(Image<I>& input)
129  {
130  init_dispatch(mln_trait_image_speed(I)(),
131  input);
132  }
133 
134  } // end of namespace mln::accu::image::internal
135 
136 
137  // Facade.
138 
139  template <typename I>
140  void
141  init(Image<I>& input)
142  {
143  mln_trace("accu::image::init");
144 
145  mlc_is_a(mln_value(I), Accumulator)::check();
146 
147  mln_precondition(exact(input).is_valid());
148  internal::init_dispatch(input);
149 
150  }
151 
152 # endif // ! MLN_INCLUDE_ONLY
153 
154  } // end of namespace mln::accu::image
155 
156  } // end of namespace mln::accu
157 
158 } // end of namespace mln
159 
160 
161 #endif // ! MLN_ACCU_IMAGE_INIT_HH