27 #ifndef MLN_CORE_IMAGE_VMORPH_THRUBIN_IMAGE_HH
28 # define MLN_CORE_IMAGE_VMORPH_THRUBIN_IMAGE_HH
35 # include <mln/core/internal/image_value_morpher.hh>
36 # include <mln/core/concept/meta_function.hh>
37 # include <mln/metal/bexpr.hh>
38 # include <mln/trait/functions.hh>
45 template <
typename I1,
typename I2,
typename F>
class thrubin_image;
50 template <
typename I1,
typename I2,
typename F>
51 struct data< thrubin_image<I1, I2, F> >
53 data(I1& ima1, I2& ima2,
const F& f);
66 template <
typename I1,
typename I2,
typename F>
67 struct image_< thrubin_image<I1, I2, F> > : image_< I1 >
70 typedef trait::image::category::value_morpher category;
71 typedef mln_internal_trait_image_speed_from(I1) speed;
72 typedef trait::image::value_access::computed value_access;
73 typedef trait::image::vw_io::read vw_io;
81 template <typename I1, typename I2, typename F>
101 typedef value lvalue;
103 rvalue operator()(const mln_psite(I1)& p) const;
104 rvalue operator()(const mln_psite(I1)& p);
106 void init_(I1& ima1, I2& ima2, const F& f);
112 template <typename I1, typename I2, typename F>
117 template <typename I1, typename I2, typename F>
120 const
Image<I1>& ima1, const
Image<I2>& ima2);
122 template <typename I1, typename I2, typename M>
123 thrubin_image<I1, I2, mln_fun_withbin(M, mln_value(I1), mln_value(I2))>
126 template <typename I1, typename I2, typename M>
127 const
thrubin_image<const I1, const I2, mln_fun_withbin(M, mln_value(I1), mln_value(I2))>
130 # ifndef MLN_INCLUDE_ONLY
137 template <
typename I1,
typename I2,
typename F>
140 : ima_(ima1), ima2_(ima2),
149 template <
typename I1,
typename I2,
typename F>
155 template <
typename I1,
typename I2,
typename F>
157 thrubin_image<I1, I2, F>::thrubin_image(I1& ima1, I2& ima2,
const F& f)
159 mln_precondition(ima1.is_valid());
160 mln_precondition(ima2.is_valid());
161 init_(ima1, ima2, f);
164 template <
typename I1,
typename I2,
typename F>
166 thrubin_image<I1, I2, F>::thrubin_image(I1& ima1, I2& ima2)
168 mln_precondition(ima1.is_valid());
169 mln_precondition(ima2.is_valid());
170 init_(ima1, ima2, F());
173 template <
typename I1,
typename I2,
typename F>
176 thrubin_image<I1, I2, F>::init_(I1& ima1, I2& ima2,
const F& f)
178 mln_precondition(! this->is_valid());
179 mln_precondition(ima1.is_valid());
180 mln_precondition(ima2.is_valid());
181 this->data_ =
new internal::data< thrubin_image<I1, I2, F> >(ima1, ima2, f);
184 template <
typename I1,
typename I2,
typename F>
192 template <
typename I1,
typename I2,
typename F>
197 mln_precondition(this->is_valid());
198 return this->data_->f_(this->data_->ima_(p), this->data_->ima2_(p));
201 template <
typename I1,
typename I2,
typename F>
203 typename thrubin_image<I1, I2, F>::rvalue
204 thrubin_image<I1, I2, F>::operator()(
const mln_psite(I1)& p)
206 mln_precondition(this->is_valid());
207 return this->data_->f_(this->data_->ima_(p), this->data_->ima2_(p));
211 template <
typename I1,
typename I2,
typename F>
212 thrubin_image<I1, I2, F>
214 Image<I1>& ima1, Image<I2>& ima2)
216 thrubin_image<I1, I2, F> tmp(exact(ima1), exact(ima2), exact(f).state());
220 template <
typename I1,
typename I2,
typename F>
221 const thrubin_image<const I1, const I2, F>
223 const Image<I1>& ima1,
const Image<I2>& ima2)
225 thrubin_image<const I1, const I2, F> tmp(exact(ima1), exact(ima2), exact(f).state());
229 template <
typename I1,
typename I2,
typename M>
230 thrubin_image<I1, I2, mln_fun_withbin(M, mln_value(I1), mln_value(I2))>
233 typedef mln_fun_withbin(M, mln_value(I1), mln_value(I2)) F;
234 thrubin_image<I1, I2, F> tmp(exact(ima1), exact(ima2), F(exact(f).state()));
239 template <typename I1, typename I2, typename M>
240 const thrubin_image<const I1, const I2, mln_fun_withbin(M, mln_value(I1), mln_value(I2))>
241 thru(const mln::Meta_Function<M>& f, const Image<I1>& ima1, const Image<I2>& ima2)
243 typedef mln_fun_withbin(M, mln_value(I1), mln_value(I2)) F;
244 thrubin_image<const I1, const I2, F> tmp(exact(ima1), exact(ima2), F(exact(f).state()));
249 # endif // ! MLN_INCLUDE_ONLY
254 #endif // ! MLN_CORE_IMAGE_VMORPH_THRUBIN_IMAGE_HH