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
00027
00028
00029 #ifndef OLENA_CONVOL_CONVOLUTION_HH__
00030 # define OLENA_CONVOL_CONVOLUTION_HH__
00031
00032 # include <oln/basics.hh>
00033 # include <oln/basics2d.hh>
00034 # include <ntg/all.hh>
00035 # include <mlc/cmp.hh>
00036 # include <mlc/array/all.hh>
00037
00038 namespace oln {
00039
00042 namespace convol {
00043
00046 namespace slow {
00047
00060 template<class DestValue, class I, class Win>
00061 typename mute<I, DestValue>::ret
00062 convolve(const abstract::image < I >& input,
00063 const abstract::w_window< Win >& win)
00064 {
00065 mlc::eq<I::dim, Win::dim>::ensure();
00066
00067 typename mute<I, DestValue>::ret output(input.size());
00068 input.border_adapt_copy(win.delta());
00069 oln_iter_type(I) p_im(input);
00070 for_all(p_im)
00071 {
00072 DestValue sum = ntg_zero_val(DestValue);
00073 for (unsigned i = 0; i < win.card(); ++i)
00074 sum += static_cast<DestValue> (win.w(i)) *
00075 static_cast<DestValue> (input[p_im - win.dp(i)]);
00076 output[p_im] = sum;
00077 }
00078
00079 return output;
00080 }
00081
00095 template<class DestValue, class I, class Info, class Win>
00096 typename mute<I, DestValue>::ret
00097 convolve(const abstract::image < I >& input,
00098 const mlc::array2d<Info, Win >& arr)
00099 {
00100 return convolve<DestValue>(input, static_cast< w_window2d<Win> >(arr));
00101
00102 }
00103
00104 }
00105
00106 }
00107
00108 }
00109
00110 #endif // OLENA_CONVOL_CONVOLUTION_HH__