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_OPT_AT_HH
00027 # define MLN_OPT_AT_HH
00028
00032
00033 # include <mln/core/concept/image.hh>
00034 # include <mln/trait/images.hh>
00035 # include <mln/trace/all.hh>
00036
00037 # include <mln/core/alias/point1d.hh>
00038 # include <mln/core/alias/point2d.hh>
00039 # include <mln/core/alias/point3d.hh>
00040
00041 namespace mln
00042 {
00043
00044 namespace opt
00045 {
00046
00049 template <typename I>
00050 mln_rvalue(I) at(const Image<I>& ima, def::coord ind);
00051
00053 template <typename I>
00054 mln_lvalue(I) at(Image<I>& ima, def::coord ind);
00055
00056
00059 template <typename I>
00060 mln_rvalue(I) at(const Image<I>& ima, def::coord row, def::coord col);
00061
00063 template <typename I>
00064 mln_lvalue(I) at(Image<I>& ima, def::coord row, def::coord col);
00065
00069 template <typename I>
00070 mln_rvalue(I) at(const Image<I>& ima,
00071 def::coord sli, def::coord row, def::coord col);
00072
00073
00074
00077 template <typename I>
00078 mln_lvalue(I) at(Image<I>& ima,
00079 def::coord sli, def::coord row, def::coord col);
00080
00081
00082 # ifndef MLN_INCLUDE_ONLY
00083
00084
00086 namespace impl
00087 {
00088
00089 template <typename I>
00090 inline
00091 mln_rvalue(I) at_1d_impl(trait::image::category::domain_morpher,
00092 const Image<I>& ima, def::coord ind)
00093 {
00094 point1d p(ind);
00095 return exact(ima)(p);
00096 }
00097
00098 template <typename I>
00099 inline
00100 mln_rvalue(I) at_1d_impl(trait::image::category::morpher,
00101 const Image<I>& ima, def::coord ind)
00102 {
00103
00104
00105 return at(*exact(ima).delegatee_(), ind);
00106 }
00107
00108 template <typename I>
00109 inline
00110 mln_rvalue(I) at_1d_impl(trait::image::category::primary,
00111 const Image<I>& ima, def::coord ind)
00112 {
00113 return exact(ima).at_(ind);
00114 }
00115
00116
00117 template <typename I>
00118 inline
00119 mln_lvalue(I) at_1d_impl(trait::image::category::domain_morpher,
00120 Image<I>& ima, def::coord ind)
00121 {
00122 mlc_is(mln_trait_image_pw_io(I),
00123 trait::image::pw_io::read_write)::check();
00124
00125 point1d p(ind);
00126 return exact(ima)(p);
00127 }
00128
00129 template <typename I>
00130 inline
00131 mln_lvalue(I) at_1d_impl(trait::image::category::morpher,
00132 Image<I>& ima, def::coord ind)
00133 {
00134
00135
00136 return at(*exact(ima).delegatee_(), ind);
00137 }
00138
00139 template <typename I>
00140 inline
00141 mln_lvalue(I) at_1d_impl(trait::image::category::primary,
00142 Image<I>& ima, def::coord ind)
00143 {
00144 return exact(ima).at_(ind);
00145 }
00146
00147 }
00148
00149 template <typename I>
00150 inline
00151 mln_rvalue(I) at(const Image<I>& ima, def::coord ind)
00152 {
00153 mlc_is(mln_trait_image_dimension(I),
00154 trait::image::dimension::one_d)::check();
00155
00156 return impl::at_1d_impl(mln_trait_image_category(I)(), ima, ind);
00157 }
00158
00159 template <typename I>
00160 mln_lvalue(I) at(Image<I>& ima, def::coord ind)
00161 {
00162 mlc_is(mln_trait_image_dimension(I),
00163 trait::image::dimension::one_d)::check();
00164
00165 return impl::at_1d_impl(mln_trait_image_category(I)(), ima, ind);
00166 }
00167
00168
00169
00171 namespace impl
00172 {
00173
00174 template <typename I>
00175 inline
00176 mln_rvalue(I) at_2d_impl(trait::image::category::domain_morpher,
00177 const Image<I>& ima, def::coord row, def::coord col)
00178 {
00179 point2d p(row, col);
00180 return exact(ima)(p);
00181 }
00182
00183 template <typename I>
00184 inline
00185 mln_rvalue(I) at_2d_impl(trait::image::category::morpher,
00186 const Image<I>& ima, def::coord row, def::coord col)
00187 {
00188
00189
00190 return at(*exact(ima).delegatee_(), row, col);
00191 }
00192
00193 template <typename I>
00194 inline
00195 mln_rvalue(I) at_2d_impl(trait::image::category::primary,
00196 const Image<I>& ima, def::coord row, def::coord col)
00197 {
00198 return exact(ima).at_(row, col);
00199 }
00200
00201
00202 template <typename I>
00203 inline
00204 mln_lvalue(I) at_2d_impl(trait::image::category::domain_morpher,
00205 Image<I>& ima, def::coord row, def::coord col)
00206 {
00207 mlc_is(mln_trait_image_pw_io(I),
00208 trait::image::pw_io::read_write)::check();
00209
00210 point2d p(row, col);
00211 return exact(ima)(p);
00212 }
00213
00214 template <typename I>
00215 inline
00216 mln_lvalue(I) at_2d_impl(trait::image::category::morpher,
00217 Image<I>& ima, def::coord row, def::coord col)
00218 {
00219
00220
00221 return at(*exact(ima).delegatee_(), row, col);
00222 }
00223
00224 template <typename I>
00225 inline
00226 mln_lvalue(I) at_2d_impl(trait::image::category::primary,
00227 Image<I>& ima, def::coord row, def::coord col)
00228 {
00229 return exact(ima).at_(row, col);
00230 }
00231
00232 }
00233
00234 template <typename I>
00235 inline
00236 mln_rvalue(I) at(const Image<I>& ima, def::coord row, def::coord col)
00237 {
00238 mlc_is(mln_trait_image_dimension(I),
00239 trait::image::dimension::two_d)::check();
00240
00241 return impl::at_2d_impl(mln_trait_image_category(I)(), ima, row, col);
00242 }
00243
00244 template <typename I>
00245 mln_lvalue(I) at(Image<I>& ima, def::coord row, def::coord col)
00246 {
00247 mlc_is(mln_trait_image_dimension(I),
00248 trait::image::dimension::two_d)::check();
00249
00250 return impl::at_2d_impl(mln_trait_image_category(I)(), ima, row, col);
00251 }
00252
00253
00255 namespace impl
00256 {
00257
00258 template <typename I>
00259 inline
00260 mln_rvalue(I) at_3d_impl(trait::image::category::domain_morpher,
00261 const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00262 {
00263 point3d p(sli, row, col);
00264 return exact(ima)(p);
00265 }
00266
00267 template <typename I>
00268 inline
00269 mln_rvalue(I) at_3d_impl(trait::image::category::morpher,
00270 const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00271 {
00272
00273
00274 return at(*exact(ima).delegatee_(), sli, row, col);
00275 }
00276
00277 template <typename I>
00278 inline
00279 mln_rvalue(I) at_3d_impl(trait::image::category::primary,
00280 const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00281 {
00282 return exact(ima).at_(sli, row, col);
00283 }
00284
00285
00286 template <typename I>
00287 inline
00288 mln_lvalue(I) at_3d_impl(trait::image::category::domain_morpher,
00289 Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00290 {
00291 mlc_is(mln_trait_image_pw_io(I),
00292 trait::image::pw_io::read_write)::check();
00293
00294 point3d p(sli, row, col);
00295 return exact(ima)(p);
00296 }
00297
00298 template <typename I>
00299 inline
00300 mln_lvalue(I) at_3d_impl(trait::image::category::morpher,
00301 Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00302 {
00303
00304
00305 return at(*exact(ima).delegatee_(), sli, row, col);
00306 }
00307
00308 template <typename I>
00309 inline
00310 mln_lvalue(I) at_3d_impl(trait::image::category::primary,
00311 Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00312 {
00313 return exact(ima).at_(sli, row, col);
00314 }
00315
00316 }
00317
00318 template <typename I>
00319 inline
00320 mln_rvalue(I) at(const Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00321 {
00322 mlc_is(mln_trait_image_dimension(I),
00323 trait::image::dimension::three_d)::check();
00324
00325 return impl::at_3d_impl(mln_trait_image_category(I)(),
00326 ima, sli, row, col);
00327 }
00328
00329 template <typename I>
00330 mln_lvalue(I) at(Image<I>& ima, def::coord sli, def::coord row, def::coord col)
00331 {
00332 mlc_is(mln_trait_image_dimension(I),
00333 trait::image::dimension::three_d)::check();
00334
00335 return impl::at_3d_impl(mln_trait_image_category(I)(),
00336 ima, sli, row, col);
00337 }
00338
00339 # endif // ! MLN_INCLUDE_ONLY
00340
00341 }
00342
00343 }
00344
00345
00346 #endif // ! MLN_OPT_AT_HH