$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
translate.hh
1 // Copyright (C) 2009, 2012 EPITA Research and Development Laboratory
2 // (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
30 
31 #ifndef MLN_GEOM_TRANSLATE_HH
32 # define MLN_GEOM_TRANSLATE_HH
33 
34 # include <mln/core/concept/image.hh>
35 # include <mln/core/concept/site_set.hh>
36 # include <mln/core/concept/box.hh>
37 
38 # include <mln/core/routine/extend.hh>
39 # include <mln/core/site_set/p_transformed.hh>
40 # include <mln/core/image/imorph/tr_image.hh>
41 
42 # include <mln/data/fill.hh>
43 
44 # include <mln/fun/x2x/translation.hh>
45 
46 # include <mln/literal/zero.hh>
47 
48 # include <mln/geom/bbox.hh>
49 
50 
51 namespace mln
52 {
53 
54  namespace geom
55  {
56 
73  template <typename I, typename V, typename Ext, typename S>
74  mln_concrete(I)
75  translate(const Image<I>& input,
76  const algebra::vec<mln_site_(I)::dim, V>& ref,
77  const Ext& extension, const Site_Set<S>& output_domain);
78 
79 
84  template <typename I, typename V, typename Ext>
85  mln_concrete(I)
86  translate(const Image<I>& input,
87  const algebra::vec<mln_site_(I)::dim, V>& ref,
88  const Ext& extension);
89 
90 
96  template <typename I, typename V>
97  mln_concrete(I)
98  translate(const Image<I>& input,
99  const algebra::vec<mln_site_(I)::dim, V>& ref);
100 
101 
102 
103 # ifndef MLN_INCLUDE_ONLY
104 
105 
106  template <typename I, typename V, typename Ext, typename S>
107  mln_concrete(I)
108  translate(const Image<I>& input_,
109  const algebra::vec<mln_site_(I)::dim, V>& ref,
110  const Ext& extension_, const Site_Set<S>& output_domain_)
111  {
112  mln_trace("geom::translate");
113 
114  const I& input = exact(input_);
115  const S& output_domain = exact(output_domain_);
116  const mln_exact(Ext)& extension = exact(extension_);
117  //mlc_converts_to(mln_exact(Ext), mln_value(I))::check();
118 
119  mln_precondition(input.is_valid());
120  mln_precondition(output_domain.is_valid());
121 
122  //mln_psite(I) c = geom::bbox(input).center();
123  typedef fun::x2x::translation<mln_site_(I)::dim, V> trans_t;
124  typedef p_transformed<mln_domain(I), trans_t> trans_domain_t;
125  typedef tr_image<trans_domain_t, I, trans_t> tr_ima_t;
126 
127  trans_t t(ref);
128  trans_domain_t d(input.domain(), t);
129  tr_ima_t tr_ima(d, input, t);
130 
131  mln_concrete(I) output(output_domain);
132  data::fill(output, extend(tr_ima, extension) | output_domain);
133 
134  return output;
135  }
136 
137 
138  template <typename I, typename V, typename Ext>
139  mln_concrete(I)
140  translate(const Image<I>& input,
141  const algebra::vec<mln_site_(I)::dim, V>& ref,
142  const Ext& extension)
143  {
144  // Old versions of GCC (including Apple GCC 4.0.1) do not parse
145  // correctly `mln_box(I)()'. Hence, we need to typedef
146  // `mln_box(I)' first.
147  typedef mln_domain(I) domain_t;
148  return translate(input, ref, extension, domain_t());
149  }
150 
151 
152  template <typename I, typename V>
153  mln_concrete(I)
154  translate(const Image<I>& input,
155  const algebra::vec<mln_site_(I)::dim, V>& ref)
156  {
157  return translate(input, ref, literal::zero);
158  }
159 
160 
161 # endif // ! MLN_INCLUDE_ONLY
162 
163 
164  } // end of namespace mln::geom
165 
166 } // end of namespace mln
167 
168 
169 #endif // ! MLN_GEOM_TRANSLATE_HH