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 SLOW_GAUSSIAN_HH
00030 # define SLOW_GAUSSIAN_HH
00031 # include <oln/core/image.hh>
00032 # include <ntg/float.hh>
00033 # include <oln/convol/slow_convolution.hh>
00034 # include <oln/core/behavior.hh>
00035
00036 namespace oln {
00037 namespace convol {
00038 namespace slow {
00039
00044 template <int Dim>
00045 struct gaussian_kernel
00046 {
00047 };
00048
00081 template <class I, class BE>
00082 oln_concrete_type(I)
00083 gaussian(const oln::abstract::non_vectorial_image<I> & in,
00084 const ntg::float_d sigma,
00085 const ntg::float_d radius_factor,
00086 const oln::abstract::behavior<BE> &behavior)
00087 {
00088 const typename gaussian_kernel<I::dim>::ret k
00089 = gaussian_kernel<I::dim>::kernel(sigma, radius_factor);
00090
00091
00092
00093 coord delta = 0;
00094 for (unsigned i = 0; i < I::dim; i++)
00095 if (in.size().nth(i) > delta)
00096 delta = in.size().nth(i);
00097 delta = (delta + 1) / 2;
00098 behavior.adapt_border(in, delta);
00099
00100 typename mute<I, ntg::float_d>::ret im =
00101 oln::convol::slow::convolve<ntg::float_d> (in, k);
00102 oln_concrete_type(I) out(in.size());
00103 oln_iter_type(I) it(out);
00104 for_all(it)
00105 out[it] = oln_value_type(I)(im[it]);
00106 return out;
00107 }
00108
00110 template <class I>
00111 oln_concrete_type(I)
00112 gaussian(const oln::abstract::non_vectorial_image<I> & in,
00113 const ntg::float_d sigma,
00114 const ntg::float_d radius_factor)
00115 {
00116 return gaussian(in, sigma, radius_factor, mirror_behavior<>());
00117 }
00118 }
00119 }
00120 }
00121
00122 #include "slow_gaussian.hxx"
00123 #endif // end SLOW_GAUSSIAN_HH