27 #ifndef MLN_CORE_IMAGE_DMORPH_P2P_IMAGE_HH
28 # define MLN_CORE_IMAGE_DMORPH_P2P_IMAGE_HH
34 # include <mln/core/internal/image_domain_morpher.hh>
35 # include <mln/core/concept/function.hh>
36 # include <mln/accu/shape/bbox.hh>
43 template <
typename I,
typename F>
struct p2p_image;
52 template <
typename I,
typename F>
53 struct data< p2p_image<I,F> >
55 data(I& ima,
const F& f);
68 template <
typename I,
typename F>
69 struct image_< p2p_image<I,F> > : default_image_morpher< I,
73 typedef trait::image::category::domain_morpher category;
75 typedef trait::image::ext_domain::none ext_domain;
76 typedef trait::image::ext_value::irrelevant ext_value;
77 typedef trait::image::ext_io::irrelevant ext_io;
79 typedef trait::image::vw_io::none vw_io;
80 typedef trait::image::vw_set::none vw_set;
81 typedef trait::image::value_alignment::not_aligned value_alignment;
82 typedef trait::image::value_storage::disrupted value_storage;
92 template <
typename I,
typename F>
107 void init_(I& ima,
const F& f);
111 const mln_domain(I)& domain()
const;
114 const F& fun()
const;
117 mln_rvalue(I) operator()(const mln_psite(I)&
p) const;
120 mln_morpher_lvalue(I) operator()(const mln_psite(I)&
p);
126 template <typename I, typename F>
131 template <typename I, typename F>
137 # ifndef MLN_INCLUDE_ONLY
141 template <
typename I,
typename F>
147 template <
typename I,
typename F,
typename J>
154 target.init_(ima, f);
162 template <
typename I,
typename F>
168 accu::shape::bbox<mln_site(I)> a;
169 mln_domain(I) b = ima.
domain();
181 template <typename I, typename F>
187 template <
typename I,
typename F>
194 template <
typename I,
typename F>
199 mln_precondition(! this->
is_valid());
200 this->
data_ =
new internal::data< p2p_image<I,F> >(ima, f);
203 template <
typename I,
typename F>
209 return this->
data_->b_;
212 template <
typename I,
typename F>
218 return this->
data_->f_;
221 template <
typename I,
typename F>
224 p2p_image<I,F>::operator()(const mln_psite(I)& p)
const
226 mln_precondition(this->
has(p));
227 mln_invariant(this->
data_->ima_.has(this->data_->f_.inverse(p)));
228 return this->
data_->ima_(this->
data_->f_.inverse(p));
231 template <
typename I,
typename F>
233 mln_morpher_lvalue(I)
234 p2p_image<I,F>::operator()(const mln_psite(I)& p)
236 mln_precondition(this->
has(p));
237 mln_invariant(this->
data_->ima_.has(this->data_->f_.inverse(p)));
238 return this->
data_->ima_(this->
data_->f_.inverse(p));
244 template <
typename I,
typename F>
247 apply_p2p(Image<I>& ima_,
const Function_v2v<F>& f)
249 mlc_is_a(mln_domain(I), Box)::check();
251 I& ima =
exact(ima_);
252 mln_precondition(ima.is_valid());
254 p2p_image<I,F> tmp(ima,
exact(f));
258 template <
typename I,
typename F>
260 p2p_image<const I, F>
261 apply_p2p(
const Image<I>& ima_,
const Function_v2v<F>& f)
263 mlc_is_a(mln_domain(I), Box)::check();
265 const I& ima =
exact(ima_);
266 mln_precondition(ima.is_valid());
268 p2p_image<const I, F> tmp(ima,
exact(f));
273 # endif // ! MLN_INCLUDE_ONLY
279 #endif // ! MLN_CORE_IMAGE_DMORPH_P2P_IMAGE_HH