slow_gaussian.hh

00001 // Copyright (C) 2004  EPITA Research and Development Laboratory
00002 //
00003 // This file is part of the Olena Library.  This library is free
00004 // software; you can redistribute it and/or modify it under the terms
00005 // of the GNU General Public License version 2 as published by the
00006 // Free Software Foundation.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this library; see the file COPYING.  If not, write to
00015 // the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016 // Boston, MA 02110-1301, USA.
00017 //
00018 // As a special exception, you may use this file as part of a free
00019 // software library without restriction.  Specifically, if other files
00020 // instantiate templates or use macros or inline functions from this
00021 // file, or you compile this file and link it with other files to
00022 // produce an executable, this file does not by itself cause the
00023 // resulting executable to be covered by the GNU General Public
00024 // License.  This exception does not however invalidate any other
00025 // reasons why the executable file might be covered by the GNU General
00026 // Public License.
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         // Compute Delta.
00092         // \todo FIXME: should be in the image hierarchy.
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     }//End namespace slow
00119   }// End namespace convol
00120 }// End namespace oln
00121 
00122 #include "slow_gaussian.hxx"
00123 #endif // end SLOW_GAUSSIAN_HH

Generated on Tue Feb 20 20:20:32 2007 for Olena by  doxygen 1.5.1