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_LABELING_COMPUTE_IMAGE_HH
00027 # define MLN_LABELING_COMPUTE_IMAGE_HH
00028
00038
00039 # include <mln/core/concept/image.hh>
00040 # include <mln/core/concept/accumulator.hh>
00041 # include <mln/core/concept/meta_accumulator.hh>
00042
00043 # include <mln/labeling/compute.hh>
00044
00045
00046 namespace mln
00047 {
00048
00049 namespace labeling
00050 {
00051
00062 template <typename A, typename I, typename L>
00063 mln_ch_value(L, mln_result(A))
00064 compute_image(const util::array<mln_result(A)>& a,
00065 const Image<I>& input,
00066 const Image<L>& labels,
00067 const mln_value(L)& nlabels);
00068
00080 template <typename A, typename I, typename L>
00081 inline
00082 mln_ch_value(L, mln_result(A))
00083 compute_image(const Accumulator<A>& accu,
00084 const Image<I>& input,
00085 const Image<L>& labels,
00086 const mln_value(L)& nlabels);
00087
00088
00100 template <typename A, typename I, typename L>
00101 inline
00102 mln_ch_value(L, mln_meta_accu_result(A, mln_value(I)))
00103 compute_image(const Meta_Accumulator<A>& accu,
00104 const Image<I>& input,
00105 const Image<L>& labels,
00106 const mln_value(L)& nlabels);
00107
00108
00109 # ifndef MLN_INCLUDE_ONLY
00110
00111 namespace internal
00112 {
00113
00114 template <typename A, typename L>
00115 mln_ch_value(L, A)
00116 compute_image(const util::array<A>& a,
00117 const Image<L>& labels_,
00118 const mln_value(L)& nlabels)
00119 {
00120 const L& labels = exact(labels_);
00121 (void) nlabels;
00122
00123 typedef mln_ch_value(L, A) O;
00124 O output;
00125 initialize(output, labels);
00126
00127 mln_piter(L) p(labels.domain());
00128 for_all(p)
00129 {
00130 mln_assertion(labels(p) <= nlabels);
00131 output(p) = a[labels(p)];
00132 }
00133
00134 return output;
00135 }
00136
00137 }
00138
00139
00140 template <typename A, typename I, typename L>
00141 inline
00142 mln_ch_value(L, mln_result(A))
00143 compute_image(const util::array<mln_result(A)>& a,
00144 const Image<L>& labels,
00145 const mln_value(L)& nlabels)
00146 {
00147 (void) nlabels;
00148
00149 trace::entering("labeling::compute_image");
00150
00151 mln_ch_value(L, mln_result(A)) output =
00152 labeling::internal::compute_image(a, labels, nlabels);
00153
00154 trace::exiting("labeling::compute_image");
00155 return output;
00156 }
00157
00158 template <typename A, typename I, typename L>
00159 inline
00160 mln_ch_value(L, mln_result(A))
00161 compute_image(const Accumulator<A>& accu,
00162 const Image<I>& input,
00163 const Image<L>& labels,
00164 const mln_value(L)& nlabels)
00165 {
00166 trace::entering("labeling::compute_image");
00167
00168 util::array<mln_result(A)> res =
00169 compute(accu, input, labels, nlabels);
00170
00171 mln_ch_value(L, mln_result(A)) output =
00172 internal::compute_image(res, labels, nlabels);
00173
00174 trace::exiting("labeling::compute_image");
00175 return output;
00176 }
00177
00178 template <typename A, typename I, typename L>
00179 inline
00180 mln_ch_value(L, mln_meta_accu_result(A, mln_value(I)))
00181 compute_image(const Meta_Accumulator<A>& accu,
00182 const Image<I>& input,
00183 const Image<L>& labels,
00184 const mln_value(L)& nlabels)
00185 {
00186 trace::entering("labeling::compute_image");
00187
00188 typedef mln_meta_accu_result(A, mln_value(I)) T;
00189
00190 util::array<T> res =
00191 compute(accu, input, labels, nlabels);
00192
00193 mln_ch_value(L, T) output =
00194 labeling::internal::compute_image(res, labels, nlabels);
00195
00196 trace::exiting("labeling::compute_image");
00197 return output;
00198 }
00199
00200 # endif // ! MLN_INCLUDE_ONLY
00201
00202 }
00203
00204 }
00205
00206 #endif // ! MLN_LABELING_COMPUTE_IMAGE_HH