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 #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       
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       
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     } 
00110 
00111 
00112     
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   } 
00144 
00145 } 
00146 
00147 
00148 #endif // ! MLN_MORPHO_COMPLEMENTATION_HH