26 #ifndef MLN_CORE_IMAGE_DMORPH_SLICE_IMAGE_HH
27 # define MLN_CORE_IMAGE_DMORPH_SLICE_IMAGE_HH
35 # include <mln/core/internal/image_domain_morpher.hh>
36 # include <mln/core/alias/box3d.hh>
37 # include <mln/core/alias/box2d.hh>
44 template <
typename I>
struct slice_image;
52 struct data< slice_image<I> >
68 struct image_< slice_image<I> > : default_image_morpher< I,
72 typedef trait::image::category::domain_morpher category;
74 typedef trait::image::dimension::two_d dimension;
80 typedef trait::image::vw_io::none vw_io;
81 typedef trait::image::vw_set::none vw_set;
82 typedef trait::image::value_alignment::not_aligned value_alignment;
83 typedef trait::image::value_storage::disrupted value_storage;
95 struct slice_image :
public internal::image_domain_morpher< I,
100 typedef slice_image< tag::image_<I> > skeleton;
112 const box2d& domain()
const;
118 mln_rvalue(I) operator()(const
point2d& p) const;
121 mln_morpher_lvalue(I) operator()(const
point2d& p);
125 operator slice_image<const I>() const;
130 template <typename I>
132 slice(Image<I>& ima, def::coord sli);
134 template <typename I>
136 slice(const Image<I>& ima, def::coord sli);
144 template <
typename I,
typename V>
145 struct ch_value< slice_image<I>, V >
147 typedef image2d<V> ret;
154 # ifndef MLN_INCLUDE_ONLY
176 template <
typename I>
182 b_ = make::box2d(ima.domain().pmin().row(), ima.domain().pmin().col(),
183 ima.domain().pmax().row(), ima.domain().pmax().col());
191 template <
typename I>
193 slice_image<I>::slice_image()
197 template <
typename I>
199 slice_image<I>::slice_image(I& ima, def::coord sli)
204 template <
typename I>
207 slice_image<I>::init_(I& ima, def::coord sli)
209 mln_precondition(! this->is_valid());
210 this->data_ =
new internal::data< slice_image<I> >(ima, sli);
213 template <
typename I>
216 slice_image<I>::domain()
const
218 mln_precondition(this->is_valid());
219 return this->data_->b_;
222 template <
typename I>
225 slice_image<I>::sli()
const
227 mln_precondition(this->is_valid());
228 return this->data_->sli_;
231 template <
typename I>
234 slice_image<I>::operator()(const point2d& p)
const
236 mln_precondition(this->
has(p));
237 point3d p_(this->data_->sli_, p.row(), p.col());
238 mln_precondition(this->data_->ima_.has(p_));
239 return this->data_->ima_(p_);
242 template <
typename I>
244 mln_morpher_lvalue(I)
245 slice_image<I>::operator()(const point2d& p)
247 mln_precondition(this->
has(p));
248 point3d p_(this->data_->sli_, p.row(), p.col());
249 mln_precondition(this->data_->ima_.has(p_));
250 return this->data_->ima_(p_);
253 template <
typename I>
255 slice_image<I>::operator slice_image<const I>()
const
257 mln_precondition(this->is_valid());
258 slice_image<const I> tmp(this->data_->ima_,
266 template <
typename I>
269 slice(Image<I>& ima_, def::coord sli)
271 mlc_equal(mln_domain(I), box3d)::check();
273 I& ima = exact(ima_);
274 mln_precondition(ima.is_valid());
275 mln_precondition(sli >= ima.domain().pmin().sli() &&
276 sli <= ima.domain().pmax().sli());
278 slice_image<I> tmp(ima, sli);
282 template <
typename I>
285 slice(
const Image<I>& ima_, def::coord sli)
287 mlc_equal(mln_domain(I), box3d)::check();
289 const I& ima = exact(ima_);
290 mln_precondition(ima.is_valid());
291 mln_precondition(sli >= ima.domain().pmin().sli() &&
292 sli <= ima.domain().pmax().sli());
294 slice_image<const I> tmp(ima, sli);
299 # endif // ! MLN_INCLUDE_ONLY
305 #endif // ! MLN_CORE_IMAGE_DMORPH_SLICE_IMAGE_HH