00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef MLN_ACCU_IMAGE_UNTAKE_HH
00027 # define MLN_ACCU_IMAGE_UNTAKE_HH
00028
00033
00034 # include <mln/core/concept/accumulator.hh>
00035 # include <mln/core/concept/image.hh>
00036 # include <mln/border/resize_equal.hh>
00037
00038
00039 namespace mln
00040 {
00041
00042 namespace accu
00043 {
00044
00045 namespace image
00046 {
00047
00048 template <typename I>
00049 void
00050 untake(Image<I>& input, const mln_deduce(I, value, argument)& arg);
00051
00052 template <typename I, typename J>
00053 void
00054 untake(Image<I>& input, const Image<J>& arg);
00055
00056
00057 # ifndef MLN_INCLUDE_ONLY
00058
00059
00060
00061
00062 namespace internal
00063 {
00064
00065 template <typename I, typename J>
00066 inline
00067 void
00068 untake_tests(Image<I>& input_, const Image<J>& arg_)
00069 {
00070 I& input = exact(input_);
00071 const J& arg = exact(arg_);
00072
00073 mln_precondition(input.is_valid());
00074 mln_precondition(arg.is_valid());
00075
00076 mln_precondition(arg.domain() <= input.domain());
00077
00078 (void) input;
00079 (void) arg;
00080 }
00081
00082 }
00083
00084
00085
00086
00087
00088 namespace impl
00089 {
00090
00091
00092
00093 namespace generic
00094 {
00095
00096 template <typename I>
00097 inline
00098 void
00099 untake(Image<I>& input_, const mln_deduce(I, value, argument)& arg)
00100 {
00101 trace::entering("accu::impl::image::generic::untake");
00102
00103 mlc_is_a(mln_value(I), Accumulator)::check();
00104
00105 I& input = exact(input_);
00106 mln_precondition(input.is_valid());
00107
00108 mln_piter(I) p(input.domain());
00109 for_all(p)
00110 input(p).untake(arg);
00111
00112 trace::exiting("accu::impl::image::generic::untake");
00113 }
00114
00115 template <typename I, typename J>
00116 inline
00117 void
00118 untake(Image<I>& input_, const Image<J>& arg_)
00119 {
00120 trace::entering("accu::impl::image::generic::untake");
00121
00122 mlc_is_a(mln_value(I), Accumulator)::check();
00123 mlc_converts_to(mln_value(J), mln_deduce(I, value, argument))::check();
00124
00125 I& input = exact(input_);
00126 const J& arg = exact(arg_);
00127
00128 internal::untake_tests(input, arg);
00129
00130 mln_piter(J) p(arg.domain());
00131 for_all(p)
00132 input(p).untake(arg(p));
00133
00134 trace::exiting("accu::impl::image::generic::untake");
00135 }
00136
00137 }
00138
00139
00140
00141
00142 template <typename I>
00143 inline
00144 void
00145 untake_fastest(Image<I>& input_, const mln_deduce(I, value, argument)& arg)
00146 {
00147 trace::entering("accu::impl::image::untake_fastest");
00148
00149 mlc_is_a(mln_value(I), Accumulator)::check();
00150
00151 I& input = exact(input_);
00152 mln_precondition(input.is_valid());
00153
00154 mln_pixter(I) px(input);
00155 for_all(px)
00156 px.val().untake(arg);
00157
00158 trace::exiting("accu::impl::image::untake_fastest");
00159 }
00160
00161 template <typename I, typename J>
00162 inline
00163 void
00164 untake_fastest(Image<I>& input_, const Image<J>& arg_)
00165 {
00166 trace::entering("accu::impl::image::untake_fastest");
00167
00168 mlc_is_a(mln_value(I), Accumulator)::check();
00169 mlc_converts_to(mln_value(J), mln_deduce(I, value, argument))::check();
00170
00171 I& input = exact(input_);
00172 const J& arg = exact(arg_);
00173
00174 internal::untake_tests(input, arg);
00175
00176 mln_precondition(arg.domain() == input.domain());
00177
00178 border::resize_equal(input, arg);
00179
00180 mln_pixter(I) p_in(input);
00181 mln_pixter(const J) p_arg(arg);
00182 for_all_2(p_in, p_arg)
00183 p_in.val().untake( p_arg.val() );
00184
00185 trace::exiting("accu::impl::image::untake_fastest");
00186 }
00187
00188 }
00189
00190
00191
00192
00193
00194 namespace internal
00195 {
00196
00197
00198
00199 template <typename I>
00200 inline
00201 void
00202 untake_dispatch(trait::image::speed::any,
00203 Image<I>& input, const mln_deduce(I, value, argument)& arg)
00204 {
00205 impl::generic::untake(input, arg);
00206 }
00207
00208 template <typename I>
00209 inline
00210 void
00211 untake_dispatch(trait::image::speed::fastest,
00212 Image<I>& input, const mln_deduce(I, value, argument)& arg)
00213 {
00214 impl::untake_fastest(input, arg);
00215 }
00216
00217 template <typename I>
00218 inline
00219 void
00220 untake_dispatch(Image<I>& input, const mln_deduce(I, value, argument)& arg)
00221 {
00222 untake_dispatch(mln_trait_image_speed(I)(),
00223 input, arg);
00224 }
00225
00226
00227
00228 template <typename I, typename J>
00229 inline
00230 void
00231 untake_dispatch(trait::image::speed::any,
00232 trait::image::speed::any,
00233 Image<I>& input, const Image<J>& arg)
00234 {
00235 impl::generic::untake(input, arg);
00236 }
00237
00238 template <typename I, typename J>
00239 inline
00240 void
00241 untake_dispatch(trait::image::speed::fastest,
00242 trait::image::speed::fastest,
00243 Image<I>& input, const Image<J>& arg)
00244 {
00245 if (exact(arg).domain() == exact(input).domain())
00246 impl::untake_fastest(input, arg);
00247 else
00248 impl::generic::untake(input, arg);
00249 }
00250
00251 template <typename I, typename J>
00252 inline
00253 void
00254 untake_dispatch(Image<I>& input, const Image<J>& arg)
00255 {
00256 untake_dispatch(mln_trait_image_speed(I)(),
00257 mln_trait_image_speed(J)(),
00258 input, arg);
00259 }
00260
00261 }
00262
00263
00264
00265
00266 template <typename I>
00267 inline
00268 void
00269 untake(Image<I>& input, const mln_deduce(I, value, argument)& arg)
00270 {
00271 trace::entering("accu::image::untake");
00272
00273 typedef mln_value(I) A;
00274 mlc_is_a(A, Accumulator)::check();
00275 mlc_equal(mln_trait_accumulator_has_untake(A),
00276 trait::accumulator::has_untake::yes)::check();
00277
00278 mln_precondition(exact(input).is_valid());
00279 internal::untake_dispatch(input, arg);
00280
00281 trace::exiting("accu::image::untake");
00282 }
00283
00284 template <typename I, typename J>
00285 inline
00286 void
00287 untake(Image<I>& input, const Image<J>& arg)
00288 {
00289 trace::entering("accu::image::untake");
00290
00291 typedef mln_value(I) A;
00292 mlc_is_a(A, Accumulator)::check();
00293 mlc_equal(mln_trait_accumulator_has_untake(A),
00294 trait::accumulator::has_untake::yes)::check();
00295 mlc_converts_to(mln_value(J), mln_deduce(I, value, argument))::check();
00296
00297 internal::untake_tests(input, arg);
00298 internal::untake_dispatch(input, arg);
00299
00300 trace::exiting("accu::image::untake");
00301 }
00302
00303 # endif // ! MLN_INCLUDE_ONLY
00304
00305 }
00306
00307 }
00308
00309 }
00310
00311
00312 #endif // ! MLN_ACCU_IMAGE_UNTAKE_HH