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

complementation.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_MORPHO_COMPLEMENTATION_HH
00027 # define MLN_MORPHO_COMPLEMENTATION_HH
00028 
00036 # include <mln/data/compare.hh>
00037 # include <mln/logical/not.hh>
00038 # include <mln/arith/revert.hh>
00039 
00040 
00041 namespace mln
00042 {
00043 
00044   namespace morpho
00045   {
00046 
00051     template <typename I>
00052     mln_concrete(I) complementation(const Image<I>& input);
00053 
00054 
00059     template <typename I>
00060     void complementation_inplace(Image<I>& input);
00061 
00062 
00063 # ifndef MLN_INCLUDE_ONLY
00064 
00065     namespace impl
00066     {
00067 
00068       // Binary => morphology on sets.
00069 
00070       template <typename I>
00071       inline
00072       mln_concrete(I)
00073         complementation_(trait::image::kind::logic,
00074                          const Image<I>& input)
00075       {
00076         return logical::not_(input);
00077       }
00078 
00079       template <typename I>
00080       inline
00081       void
00082       complementation_inplace_(trait::image::kind::logic,
00083                                Image<I>& input)
00084       {
00085         logical::not_inplace(input);
00086       }
00087 
00088 
00089       // Otherwise => morphology on functions.
00090 
00091       template <typename I>
00092       inline
00093       mln_concrete(I)
00094         complementation_(trait::image::kind::any,
00095                          const Image<I>& input)
00096       {
00097         return arith::revert(input);
00098       }
00099 
00100       template <typename I>
00101       inline
00102       void
00103         complementation_inplace_(trait::image::kind::any,
00104                                  Image<I>& input)
00105       {
00106         arith::revert_inplace(input);
00107       }
00108 
00109     } // end of namespace mln::morpho::impl
00110 
00111 
00112     // Facades.
00113 
00114     template <typename I>
00115     inline
00116     mln_concrete(I) complementation(const Image<I>& input)
00117     {
00118       trace::entering("morpho::complementation");
00119       mln_precondition(exact(input).is_valid());
00120 
00121       mln_concrete(I) output = impl::complementation_(mln_trait_image_kind(I)(),
00122                                                       input);
00123 
00124       trace::exiting("morpho::complementation");
00125       return output;
00126     }
00127 
00128     template <typename I>
00129     inline
00130     void complementation_inplace(Image<I>& input)
00131     {
00132       trace::entering("morpho::complementation_inplace");
00133       mln_precondition(exact(input).is_valid());
00134 
00135       impl::complementation_inplace_(mln_trait_image_kind(I)(),
00136                                      input);
00137 
00138       trace::exiting("morpho::complementation_inplace");
00139     }
00140 
00141 # endif // ! MLN_INCLUDE_ONLY
00142 
00143   } // end of namespace mln::morpho
00144 
00145 } // end of namespace mln
00146 
00147 
00148 #endif // ! MLN_MORPHO_COMPLEMENTATION_HH

Generated on Tue Oct 4 2011 15:23:37 for Milena (Olena) by  doxygen 1.7.1