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

compute_image.hh

00001 // Copyright (C) 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_LABELING_COMPUTE_IMAGE_HH
00027 # define MLN_LABELING_COMPUTE_IMAGE_HH
00028 
00038 
00039 # include <mln/core/concept/image.hh>
00040 # include <mln/core/concept/accumulator.hh>
00041 # include <mln/core/concept/meta_accumulator.hh>
00042 
00043 # include <mln/labeling/compute.hh>
00044 
00045 
00046 namespace mln
00047 {
00048 
00049   namespace labeling
00050   {
00051 
00062     template <typename A, typename I, typename L>
00063     mln_ch_value(L, mln_result(A))
00064       compute_image(const util::array<mln_result(A)>& a,
00065                     const Image<I>& input,
00066                     const Image<L>& labels,
00067                     const mln_value(L)& nlabels);
00068 
00080     template <typename A, typename I, typename L>
00081     inline
00082     mln_ch_value(L, mln_result(A))
00083       compute_image(const Accumulator<A>& accu,
00084                     const Image<I>& input,
00085                     const Image<L>& labels,
00086                     const mln_value(L)& nlabels);
00087 
00088 
00100     template <typename A, typename I, typename L>
00101     inline
00102     mln_ch_value(L, mln_meta_accu_result(A, mln_value(I)))
00103       compute_image(const Meta_Accumulator<A>& accu,
00104                     const Image<I>& input,
00105                     const Image<L>& labels,
00106                     const mln_value(L)& nlabels);
00107 
00108 
00109 # ifndef MLN_INCLUDE_ONLY
00110 
00111     namespace internal
00112     {
00113 
00114       template <typename A, typename L>
00115       mln_ch_value(L, A)
00116         compute_image(const util::array<A>& a,
00117                       const Image<L>& labels_,
00118                       const mln_value(L)& nlabels)
00119       {
00120         const L& labels = exact(labels_);
00121         (void) nlabels;
00122 
00123         typedef mln_ch_value(L, A) O;
00124         O output;
00125         initialize(output, labels);
00126 
00127         mln_piter(L) p(labels.domain());
00128         for_all(p)
00129         {
00130           mln_assertion(labels(p) <= nlabels);
00131           output(p) = a[labels(p)];
00132         }
00133 
00134         return output;
00135       }
00136 
00137     } // end of namespace mln::labeling::internal
00138 
00139 
00140     template <typename A, typename I, typename L>
00141     inline
00142     mln_ch_value(L, mln_result(A))
00143       compute_image(const util::array<mln_result(A)>& a,
00144                     const Image<L>& labels,
00145                     const mln_value(L)& nlabels)
00146     {
00147       (void) nlabels;
00148 
00149       trace::entering("labeling::compute_image");
00150 
00151       mln_ch_value(L, mln_result(A)) output =
00152         labeling::internal::compute_image(a, labels, nlabels);
00153 
00154       trace::exiting("labeling::compute_image");
00155       return output;
00156     }
00157 
00158     template <typename A, typename I, typename L>
00159     inline
00160     mln_ch_value(L, mln_result(A))
00161       compute_image(const Accumulator<A>& accu,
00162                     const Image<I>& input,
00163                     const Image<L>& labels,
00164                     const mln_value(L)& nlabels)
00165     {
00166       trace::entering("labeling::compute_image");
00167 
00168       util::array<mln_result(A)> res =
00169         compute(accu, input, labels, nlabels);
00170 
00171       mln_ch_value(L, mln_result(A)) output =
00172         internal::compute_image(res, labels, nlabels);
00173 
00174       trace::exiting("labeling::compute_image");
00175       return output;
00176     }
00177 
00178     template <typename A, typename I, typename L>
00179     inline
00180     mln_ch_value(L, mln_meta_accu_result(A, mln_value(I)))
00181       compute_image(const Meta_Accumulator<A>& accu,
00182                     const Image<I>& input,
00183                     const Image<L>& labels,
00184                     const mln_value(L)& nlabels)
00185     {
00186       trace::entering("labeling::compute_image");
00187 
00188       typedef mln_meta_accu_result(A, mln_value(I)) T;
00189 
00190       util::array<T> res =
00191         compute(accu, input, labels, nlabels);
00192 
00193       mln_ch_value(L, T) output =
00194         labeling::internal::compute_image(res, labels, nlabels);
00195 
00196       trace::exiting("labeling::compute_image");
00197       return output;
00198     }
00199 
00200 # endif // ! MLN_INCLUDE_ONLY
00201 
00202   } // end of namespace mln::labeling
00203 
00204 } // end of namespace mln
00205 
00206 #endif // ! MLN_LABELING_COMPUTE_IMAGE_HH

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