• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

lap.hh

00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
00025 
00026 #ifndef MLN_LINEAR_LAP_HH
00027 # define MLN_LINEAR_LAP_HH
00028 
00034 # include <mln/linear/convolve.hh>
00035 # include <mln/make/w_window2d.hh>
00036 
00037 
00038 
00039 namespace mln
00040 {
00041 
00042   namespace linear
00043   {
00044 
00045     // FIXME: Doc!
00046 
00047     template <typename I>
00048     mln_ch_convolve(I, int)
00049     lap_4(const Image<I>& input);
00050 
00051     template <typename I>
00052     mln_ch_convolve(I, int)
00053     lap_8(const Image<I>& input);
00054 
00055     template <typename I>
00056     mln_ch_convolve(I, int)
00057     lap_x(const Image<I>& input);
00058 
00059     template <typename I>
00060     mln_ch_convolve(I, int)
00061     lap_o(const Image<I>& input);
00062 
00063 
00064 # ifndef MLN_INCLUDE_ONLY
00065 
00066     // Laplacian operators (Cf. Sonka et al., p. 81)
00067 
00068     template <typename I>
00069     inline
00070     mln_ch_convolve(I, int)
00071     lap_4(const Image<I>& input)
00072     {
00073       trace::entering("linear::lap_4");
00074       mln_precondition(exact(input).is_valid());
00075       int ws[] = { 0,  1,  0,
00076                    1, -4,  1,
00077                    0,  1,  0 };
00078       mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
00079       trace::exiting("linear::lap_4");
00080       return output;
00081     }
00082 
00083     template <typename I>
00084     inline
00085     mln_ch_convolve(I, int)
00086     lap_8(const Image<I>& input)
00087     {
00088       trace::entering("linear::lap_8");
00089       mln_precondition(exact(input).is_valid());
00090       int ws[] = { 1,  1,  1,
00091                    1, -8,  1,
00092                    1,  1,  1 };
00093       mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
00094       trace::exiting("linear::lap_8");
00095       return output;
00096     }
00097 
00098     template <typename I>
00099     inline
00100     mln_ch_convolve(I, int)
00101     lap_x(const Image<I>& input)
00102     {
00103       trace::entering("linear::lap_x");
00104       mln_precondition(exact(input).is_valid());
00105       int ws[] = { +2, -1, +2,
00106                    -1, -4, -1,
00107                    +2, -1, +2 };
00108       mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
00109       trace::exiting("linear::lap_x");
00110       return output;
00111     }
00112 
00113     template <typename I>
00114     inline
00115     mln_ch_convolve(I, int)
00116     lap_o(const Image<I>& input)
00117     {
00118       trace::entering("linear::lap_o");
00119       mln_precondition(exact(input).is_valid());
00120       int ws[] = { -1, +2, -1,
00121                    +2, -4, +2,
00122                    -1, +2, -1 };
00123       mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
00124       trace::exiting("linear::lap_o");
00125       return output;
00126     }
00127 
00128 # endif // ! MLN_INCLUDE_ONLY
00129 
00130   } // end of namespace mln::linear
00131 
00132 } // end of namespace mln
00133 
00134 
00135 #endif // ! MLN_LINEAR_LAP_HH

Generated on Fri Sep 16 2011 16:33:41 for Milena (Olena) by  doxygen 1.7.1