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_MAKE_W_WINDOW_DIRECTIONAL_HH
00027 # define MLN_MAKE_W_WINDOW_DIRECTIONAL_HH
00028 
00032 
00033 # include <mln/core/w_window.hh>
00034 # include <mln/core/concept/gdpoint.hh>
00035 # include <mln/literal/zero.hh>
00036 
00037 
00038 namespace mln
00039 {
00040 
00041   namespace make
00042   {
00043 
00051     template <typename D, typename W, unsigned L>
00052     mln::w_window<D,W>
00053     w_window_directional(const Gdpoint<D>& dp, W (&weights)[L]);
00054 
00055 
00056 # ifndef MLN_INCLUDE_ONLY
00057 
00058     template <typename D, typename W, unsigned L>
00059     inline
00060     mln::w_window<D,W>
00061     w_window_directional(const Gdpoint<D>& dp_, W (&weights)[L])
00062     {
00063       mlc_bool(L % 2 == 1)::check();
00064       int half = L / 2;
00065 
00066       const D& dp = exact(dp_);
00067       D zero = literal::zero;
00068       mln_precondition(dp != zero);
00069 
00070       mln::w_window<D,W> w_win;
00071       for (int i = - half; i <= half; ++i)
00072         if (weights[half + i] != 0)
00073           w_win.insert(weights[half + i], zero + dp * i);
00074       return w_win;
00075     }
00076 
00077 # endif // ! MLN_INCLUDE_ONLY
00078 
00079   } 
00080 
00081 } 
00082 
00083 
00084 #endif // ! MLN_MAKE_W_WINDOW_DIRECTIONAL_HH