• 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 
00122         typedef mln_ch_value(L, A) O;
00123         O output;
00124         initialize(output, labels);
00125 
00126         mln_piter(L) p(labels.domain());
00127         for_all(p)
00128         {
00129           mln_assertion(labels(p) < nlabels);
00130           output(p) = a[labels(p)];
00131         }
00132 
00133         return output;
00134       }
00135 
00136     } // end of namespace mln::labeling::internal
00137 
00138 
00139     template <typename A, typename I, typename L>
00140     inline
00141     mln_ch_value(L, mln_result(A))
00142       compute_image(const util::array<mln_result(A)>& a,
00143                     const Image<L>& labels,
00144                     const mln_value(L)& nlabels)
00145     {
00146       (void) nlabels;
00147 
00148       trace::entering("labeling::compute_image");
00149 
00150       mln_ch_value(L, mln_result(A)) output =
00151         labeling::internal::compute_image(a, labels, nlabels);
00152 
00153       trace::exiting("labeling::compute_image");
00154       return output;
00155     }
00156 
00157     template <typename A, typename I, typename L>
00158     inline
00159     mln_ch_value(L, mln_result(A))
00160       compute_image(const Accumulator<A>& accu,
00161                     const Image<I>& input,
00162                     const Image<L>& labels,
00163                     const mln_value(L)& nlabels)
00164     {
00165       trace::entering("labeling::compute_image");
00166 
00167       util::array<mln_result(A)> res =
00168         compute(accu, input, labels, nlabels);
00169 
00170       mln_ch_value(L, mln_result(A)) output =
00171         internal::compute_image(res, labels, nlabels);
00172 
00173       trace::exiting("labeling::compute_image");
00174       return output;
00175     }
00176 
00177     template <typename A, typename I, typename L>
00178     inline
00179     mln_ch_value(L, mln_meta_accu_result(A, mln_value(I)))
00180       compute_image(const Meta_Accumulator<A>& accu,
00181                     const Image<I>& input,
00182                     const Image<L>& labels,
00183                     const mln_value(L)& nlabels)
00184     {
00185       trace::entering("labeling::compute_image");
00186 
00187       typedef mln_meta_accu_result(A, mln_value(I)) T;
00188 
00189       util::array<T> res =
00190         compute(accu, input, labels, nlabels);
00191 
00192       mln_ch_value(L, T) output =
00193         labeling::internal::compute_image(res, labels, nlabels);
00194 
00195       trace::exiting("labeling::compute_image");
00196       return output;
00197     }
00198 
00199 # endif // ! MLN_INCLUDE_ONLY
00200 
00201   } // end of namespace mln::labeling
00202 
00203 } // end of namespace mln
00204 
00205 #endif // ! MLN_LABELING_COMPUTE_IMAGE_HH

Generated on Thu Sep 8 2011 18:31:44 for Milena (Olena) by  doxygen 1.7.1