$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dual_input_tree.hh
1 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
29 
30 #ifndef MLN_MORPHO_TREE_DUAL_INPUT_TREE_HH
31 # define MLN_MORPHO_TREE_DUAL_INPUT_TREE_HH
32 
33 # include <mln/data/sort_psites.hh>
34 
35 # include <mln/morpho/tree/data.hh>
36 # include <mln/morpho/tree/impl/dual_union_find.hh>
37 # include <mln/morpho/tree/impl/dual_hqueue.hh>
38 
39 namespace mln
40 {
41 
42  namespace morpho
43  {
44 
45  namespace tree
46  {
47 
56  template <typename I, typename N>
57  inline
59  dual_input_max_tree(const Image<I>& f,
60  const Image<I>& m,
61  const Neighborhood<N>& nbh);
62 
63 
64 # ifndef MLN_INCLUDE_ONLY
65 
66  namespace internal
67  {
68 
69  template <typename I, typename N>
70  inline
72  dual_input_max_tree_dispatch(trait::image::quant::any,
73  const I& f,
74  const I& m,
75  const N& nbh)
76  {
77  typedef p_array<mln_psite(I)> S;
78  typedef data<I,S> tree_t;
79 
82 
83  tree_t tree = impl::generic::dual_union_find(f, m, s_f, s_m, nbh);
84  return tree;
85  }
86 
87  template <typename I, typename N>
88  inline
90  dual_input_max_tree_dispatch(trait::image::quant::low,
91  const I& f,
92  const I& m,
93  const N& nbh)
94  {
95  typedef p_array<mln_psite(I)> S;
96  typedef data<I,S> tree_t;
97 
98  tree_t tree = impl::dual_hqueue(f, m, nbh);
99  return tree;
100  }
101 
102  } // end of namespace mln::morpho::tree::internal
103 
104 
105  // Facades.
106  template <typename I, typename N>
107  inline
108  morpho::tree::data< I, p_array<mln_psite(I)> >
109  dual_input_max_tree(const Image<I>& f_,
110  const Image<I>& m_,
111  const Neighborhood<N>& nbh_)
112  {
113  mln_trace("morpho::tree::dual_input_max_tree");
114 
115  const I& f = exact(f_);
116  const I& m = exact(m_);
117  const N& nbh = exact(nbh_);
118 
119  mln_precondition(f.is_valid());
120  mln_precondition(m.is_valid());
121  mln_precondition(nbh.is_valid());
122  mln_precondition(f.domain() == m.domain());
123 
124  typedef p_array<mln_psite(I)> S;
125  typedef data<I,S> tree_t;
126 
127  tree_t tree = internal::dual_input_max_tree_dispatch(mln_trait_image_quant(I)(), f, m, nbh);
128 
129  return tree;
130  }
131 
132 
133 
134 
135 
136 # endif // ! MLN_INCLUDE_ONLY
137 
138  } // end of namespace mln::morpho::tree
139 
140  } // end of namespace mln::morpho
141 
142 } // end of namespace mln
143 
144 
145 #endif // !MLN_MORPHO_TREE_DUAL_INPUT_TREE_HH