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_COMPUTE_HH
00027 # define MLN_ACCU_COMPUTE_HH
00028
00035
00036 # include <mln/core/concept/meta_accumulator.hh>
00037 # include <mln/core/concept/image.hh>
00038 # include <mln/util/pix.hh>
00039
00040
00041 namespace mln
00042 {
00043
00044 namespace accu
00045 {
00046
00058 template <typename A, typename I>
00059 mln_result(A)
00060 compute(const Accumulator<A>& a, const Image<I>& input);
00061
00062
00074 template <typename A, typename I>
00075 mln_meta_accu_result(A, util::pix<I>)
00076 compute(const Meta_Accumulator<A>& a, const Image<I>& input);
00077
00078
00079
00080 # ifndef MLN_INCLUDE_ONLY
00081
00082
00083 namespace impl
00084 {
00085
00086 namespace generic
00087 {
00088
00089 template <typename A, typename I>
00090 mln_result(A)
00091 compute(const Accumulator<A>&, const Image<I>& input_)
00092 {
00093 trace::entering("accu::impl::generic::compute");
00094
00095 const I& input = exact(input_);
00096 mln_precondition(input.is_valid());
00097
00098 A a;
00099 mln_piter(I) p(input.domain());
00100 for_all(p)
00101 a.take(make::pix(input, p));
00102
00103 trace::exiting("accu::impl::generic::compute");
00104 return a.to_result();
00105 }
00106
00107 }
00108
00109 }
00110
00111
00112 namespace internal
00113 {
00114
00115 template <typename A, typename I>
00116 inline
00117 mln_result(A)
00118 compute_dispatch(const Accumulator<A>& a, const Image<I>& input)
00119 {
00120 return impl::generic::compute(a, input);
00121 }
00122
00123 }
00124
00125
00126
00127 template <typename A, typename I>
00128 inline
00129 mln_result(A)
00130 compute(const Accumulator<A>& a, const Image<I>& input)
00131 {
00132 trace::entering("accu::compute");
00133
00134 mln_precondition(exact(input).is_valid());
00135 mln_result(A) output = internal::compute_dispatch(a, input);
00136
00137 trace::exiting("accu::compute");
00138 return output;
00139 }
00140
00141 template <typename A, typename I>
00142 inline
00143 mln_meta_accu_result(A, util::pix<I>)
00144 compute(const Meta_Accumulator<A>& a, const Image<I>& input)
00145 {
00146 trace::entering("accu::compute");
00147
00148 mln_precondition(exact(input).is_valid());
00149
00150 typedef mln_accu_with(A, util::pix<I>) A_;
00151 util::pix<I> pix_(exact(input), mln_psite(I)());
00152 A_ a_ = accu::unmeta(exact(a), pix_);
00153
00154 mln_result(A_) output = internal::compute_dispatch(a_, input);
00155
00156 trace::exiting("accu::compute");
00157 return output;
00158 }
00159
00160 # endif // ! MLN_INCLUDE_ONLY
00161
00162 }
00163
00164 }
00165
00166
00167 #endif // ! MLN_ACCU_COMPUTE_HH