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_TO_RESULT_HH
00027 # define MLN_ACCU_IMAGE_TO_RESULT_HH
00028
00032
00033 # include <mln/core/concept/accumulator.hh>
00034 # include <mln/core/concept/image.hh>
00035
00036
00037 namespace mln
00038 {
00039
00040 namespace accu
00041 {
00042
00043 namespace image
00044 {
00045
00046 template <typename I>
00047 mln_ch_value(I, mln_deduce(I, value, result))
00048 to_result(const Image<I>& input);
00049
00050
00051
00052 # ifndef MLN_INCLUDE_ONLY
00053
00054 namespace impl
00055 {
00056
00057
00058
00059 namespace generic
00060 {
00061
00062 template <typename I>
00063 mln_ch_value(I, mln_deduce(I, value, result))
00064 to_result(const Image<I>& input_)
00065 {
00066 trace::entering("accu::impl::image::generic::to_result");
00067
00068 mlc_is_a(mln_value(I), Accumulator)::check();
00069
00070 const I& input = exact(input_);
00071 mln_precondition(input.is_valid());
00072
00073 typedef mln_deduce(I, value, result) R;
00074 mln_ch_value(I, R) output;
00075 initialize(output, input);
00076
00077 mln_piter(I) p(input.domain());
00078 for_all(p)
00079 output(p) = input(p).to_result();
00080
00081 trace::exiting("accu::impl::image::generic::to_result");
00082 return output;
00083 }
00084
00085 }
00086
00087
00088
00089
00090 template <typename I>
00091 mln_ch_value(I, mln_deduce(I, value, result))
00092 to_result_fastest(const Image<I>& input_)
00093 {
00094 trace::entering("accu::impl::image::to_result_fastest");
00095
00096 mlc_is_a(mln_value(I), Accumulator)::check();
00097
00098 const I& input = exact(input_);
00099 mln_precondition(input.is_valid());
00100
00101 typedef mln_deduce(I, value, result) R;
00102 typedef mln_ch_value(I, R) O;
00103 O output;
00104 initialize(output, input);
00105
00106 mln_pixter(const I) p_in(input);
00107 mln_pixter(O) p_out(output);
00108 for_all_2(p_in, p_out)
00109 p_out.val() = p_in.val().to_result();
00110
00111 trace::exiting("accu::impl::image::to_result_fastest");
00112 return output;
00113 }
00114
00115 }
00116
00117
00118
00119
00120
00121 namespace internal
00122 {
00123
00124 template <typename I>
00125 mln_ch_value(I, mln_deduce(I, value, result))
00126 to_result_dispatch(trait::image::speed::any,
00127 const Image<I>& input)
00128 {
00129 return impl::generic::to_result(input);
00130 }
00131
00132 template <typename I>
00133 mln_ch_value(I, mln_deduce(I, value, result))
00134 to_result_dispatch(trait::image::speed::fastest,
00135 const Image<I>& input)
00136 {
00137 return impl::to_result_fastest(input);
00138 }
00139
00140 template <typename I>
00141 mln_ch_value(I, mln_deduce(I, value, result))
00142 to_result_dispatch(const Image<I>& input)
00143 {
00144 return to_result_dispatch(mln_trait_image_speed(I)(),
00145 input);
00146 }
00147
00148 }
00149
00150
00151
00152
00153 template <typename I>
00154 mln_ch_value(I, mln_deduce(I, value, result))
00155 to_result(const Image<I>& input)
00156 {
00157 trace::entering("accu::image::to_result");
00158
00159 mlc_is_a(mln_value(I), Accumulator)::check();
00160
00161 mln_precondition(exact(input).is_valid());
00162
00163 typedef mln_deduce(I, value, result) R;
00164 mln_ch_value(I, R) output;
00165 output = internal::to_result_dispatch(input);
00166
00167 trace::exiting("accu::image::to_result");
00168 return output;
00169 }
00170
00171 # endif // ! MLN_INCLUDE_ONLY
00172
00173 }
00174
00175 }
00176
00177 }
00178
00179
00180 #endif // ! MLN_ACCU_IMAGE_TO_RESULT_HH