27 #ifndef SCRIBO_UTIL_INTEGRAL_SUB_SUM_SUM2_FUNCTOR_HH
28 # define SCRIBO_UTIL_INTEGRAL_SUB_SUM_SUM2_FUNCTOR_HH
34 # include <mln/core/concept/image.hh>
35 # include <mln/core/site_set/box.hh>
36 # include <mln/make/box2d.hh>
37 # include <mln/util/couple.hh>
47 template <
typename I,
typename S = mln_sum(mln_value(I))>
51 typedef mln_value(I) V;
58 const mln_box(I)& output_domain,
62 void take(
const V& v);
64 result to_result_first_row()
const;
71 void begin_of_first_row();
77 void init_(
unsigned scale,
const mln_box(I)& b,
unsigned border);
89 # ifndef MLN_INCLUDE_ONLY
91 template <
typename I,
typename S>
93 const mln_box(I)& output_domain,
96 init_(scale, output_domain, border);
99 template <
typename I,
typename S>
100 integral_sub_sum_sum2_functor<I,S>::integral_sub_sum_sum2_functor(
const I& ima,
105 (ima.ncols() + scale - 1) / scale);
106 init_(scale, b, ima.border());
109 template <
typename I,
typename S>
111 integral_sub_sum_sum2_functor<I,S>::init_(
unsigned scale,
const mln_box(I)& b,
116 area = scale * scale;
119 unsigned b_offset = sub.delta_offset(
dpoint2d(border, border));
120 p_sub = sub.buffer() + b_offset;
123 template <
typename I,
typename S>
126 integral_sub_sum_sum2_functor<I,S>::begin_of_first_row()
132 template <
typename I,
typename S>
135 integral_sub_sum_sum2_functor<I,S>::begin_of_row()
141 template <
typename I,
typename S>
144 integral_sub_sum_sum2_functor<I,S>::take(
const V& v)
150 template <
typename I,
typename S>
152 typename integral_sub_sum_sum2_functor<I,S>::result
153 integral_sub_sum_sum2_functor<I,S>::to_result_first_row()
const
155 return result(h_sum + local_sum, h_sum_2);
158 template <
typename I,
typename S>
160 typename integral_sub_sum_sum2_functor<I,S>::result
161 integral_sub_sum_sum2_functor<I,S>::to_result(
const result& up_result)
const
163 return result(h_sum + local_sum + up_result.first(),
164 h_sum_2 + up_result.second());
167 template <
typename I,
typename S>
170 integral_sub_sum_sum2_functor<I,S>::begin_of_col()
175 template <
typename I,
typename S>
178 integral_sub_sum_sum2_functor<I,S>::end_of_col()
184 template <
typename I,
typename S>
187 integral_sub_sum_sum2_functor<I,S>::end_of_row()
193 #endif // ! MLN_INCLUDE_ONLY
199 #endif // ! SCRIBO_UTIL_INTEGRAL_SUB_SUM_SUM2_FUNCTOR_HH