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_DATA_APPLY_HH
00027 # define MLN_DATA_APPLY_HH
00028 
00034 # include <mln/core/concept/image.hh>
00035 # include <mln/core/concept/function.hh>
00036 
00037 
00038 # include <mln/data/apply.spe.hh>
00039 
00040 
00041 namespace mln
00042 {
00043 
00044   namespace data
00045   {
00046 
00060     template <typename I, typename F>
00061     void apply(Image<I>& input, const Function_v2v<F>& f);
00062 
00063 
00064 
00065 # ifndef MLN_INCLUDE_ONLY
00066 
00067     namespace impl
00068     {
00069 
00070       namespace generic
00071       {
00072 
00073         template <typename I, typename F>
00074         inline
00075         void apply_(I& input, const F& f)
00076         {
00077           trace::entering("data::impl::generic::apply_");
00078 
00079           mln_piter(I) p(input.domain());
00080           for_all(p)
00081             input(p) = f(input(p));
00082 
00083           trace::exiting("data::impl::generic::apply_");
00084         }
00085 
00086       } 
00087 
00088     } 
00089 
00090 
00091     
00092 
00093     template <typename I, typename F>
00094     inline
00095     void apply(Image<I>& input, const Function_v2v<F>& f)
00096     {
00097       trace::entering("data::apply");
00098 
00099       mln_precondition(exact(input).is_valid());
00100       impl::apply_(mln_trait_image_speed(I)(), exact(input),
00101                    exact(f));
00102 
00103       trace::exiting("data::apply");
00104     }
00105 
00106 # endif // ! MLN_INCLUDE_ONLY
00107 
00108   } 
00109 
00110 } 
00111 
00112 
00113 #endif // ! MLN_DATA_APPLY_HH