27 #ifndef MLN_CORE_IMAGE_DMORPH_UNPROJECT_IMAGE_HH
28 # define MLN_CORE_IMAGE_DMORPH_UNPROJECT_IMAGE_HH
35 # include <mln/core/internal/image_domain_morpher.hh>
36 # include <mln/core/grids.hh>
37 # include <mln/core/site_set/box.hh>
45 template <
typename I,
typename D,
typename F>
struct unproject_image;
54 template <
typename I,
typename D,
typename F>
55 struct data< unproject_image<I,D,F> >
57 data(I& ima,
const D& dom,
const F& f);
70 template <
typename I,
typename D,
typename F>
71 struct image_< unproject_image<I,D,F> > : default_image_morpher< I,
73 unproject_image<I,D,F> >
75 typedef trait::image::category::domain_morpher
category;
80 typedef trait::image::ext_domain::none
ext_domain;
81 typedef trait::image::ext_value::irrelevant
ext_value;
82 typedef trait::image::ext_io::irrelevant
ext_io;
84 typedef trait::image::vw_io::none
vw_io;
85 typedef trait::image::vw_set::none
vw_set;
98 template <
typename I,
typename D,
typename F>
101 unproject_image<I,D,F> >
116 void init_(I& ima,
const D& dom,
const F& f);
124 mln_rvalue(I) operator()(const mln_psite(D)&
p) const;
127 mln_morpher_lvalue(I) operator()(const mln_psite(D)&
p);
136 template <typename I, typename D, typename F>
140 template <typename I, typename D, typename F>
163 # ifndef MLN_INCLUDE_ONLY
171 template <
typename I,
typename D,
typename F>
185 template <
typename I,
typename D,
typename F>
187 unproject_image<I,D,F>::unproject_image()
191 template <
typename I,
typename D,
typename F>
193 unproject_image<I,D,F>::unproject_image(I& ima,
const D& dom,
const F& f)
198 template <
typename I,
typename D,
typename F>
201 unproject_image<I,D,F>::init_(I& ima,
const D& dom,
const F& f)
203 mln_precondition(! this->is_valid());
204 this->data_ =
new internal::data< unproject_image<I,D,F> >(ima, dom, f);
207 template <
typename I,
typename D,
typename F>
210 unproject_image<I,D,F>::domain()
const
212 mln_precondition(this->is_valid());
213 return this->data_->dom_;
216 template <
typename I,
typename D,
typename F>
219 unproject_image<I,D,F>::operator()(const mln_psite(D)& p)
const
221 mln_precondition(this->
has(p));
222 mln_result(F) p_ = this->data_->f_(p);
223 mln_precondition(this->data_->ima_.has(p_));
224 return this->data_->ima_(p_);
227 template <typename I, typename D, typename F>
229 mln_morpher_lvalue(I)
230 unproject_image<I,D,F>::operator()(const mln_psite(D)& p)
232 mln_precondition(this->
has(p));
233 mln_result(F) p_ = this->data_->f_(p);
234 mln_precondition(this->data_->ima_.has(p_));
235 return this->data_->ima_(p_);
241 template <typename I, typename D, typename F>
243 unproject_image<I, D, F>
244 unproject(Image<I>& ima_, const Site_Set<D>& dom, const Function_v2v<F>& f)
246 mlc_converts_to(mln_psite(D), mln_argument(F))::check();
247 mlc_converts_to(mln_result(F), mln_psite(I))::check();
249 I& ima =
exact(ima_);
250 mln_precondition(ima.is_valid());
252 unproject_image<I,D,F> tmp(ima,
exact(dom),
exact(f));
256 template <
typename I,
typename D,
typename F>
258 unproject_image<const I, D, F>
259 unproject(
const Image<I>& ima_,
const Site_Set<D>& dom,
const Function_v2v<F>& f)
261 mlc_converts_to(mln_psite(D), mln_argument(F))::check();
262 mlc_converts_to(mln_result(F), mln_psite(I))::check();
264 const I& ima =
exact(ima_);
265 mln_precondition(ima.is_valid());
267 unproject_image<const I,D,F> tmp(ima,
exact(dom),
exact(f));
272 # endif // ! MLN_INCLUDE_ONLY
278 #endif // ! MLN_CORE_IMAGE_DMORPH_UNPROJECT_IMAGE_HH