$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
connect_lines.hh
1 // Copyright (C) 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 
26 #ifndef SCRIBO_TABLE_INTERNAL_CONNECT_LINES_HH
27 # define SCRIBO_TABLE_INTERNAL_CONNECT_LINES_HH
28 
32 
33 # include <mln/core/image/image1d.hh>
34 # include <mln/core/alias/neighb1d.hh>
35 
36 # include <mln/data/fill.hh>
37 
38 # include <mln/transform/influence_zone_geodesic_saturated.hh>
39 
40 # include <mln/morpho/elementary/dilation.hh>
41 # include <mln/util/array.hh>
42 # include <mln/util/couple.hh>
43 
44 # include <mln/opt/at.hh>
45 
46 # include <scribo/core/macros.hh>
47 # include <scribo/core/central_sites.hh>
48 
49 namespace scribo
50 {
51 
52  namespace table
53  {
54 
55  namespace internal
56  {
57 
58  using namespace mln;
59 
69  template <typename P>
70  void
71  connect_lines(const mln::util::array<int>& aligned_lines,
72  mln::util::array< box<P> >& boxes,
73  unsigned dim,
74  unsigned dim_size,
75  unsigned max_distance);
76 
77 
78 # ifndef MLN_INCLUDE_ONLY
79 
80 
81  template <typename P>
82  void
83  connect_lines(const mln::util::array<int>& aligned_lines,
84  mln::util::array< box<P> >& boxes,
85  unsigned dim,
86  unsigned dim_size,
87  unsigned max_distance)
88  {
89  mln_trace("scribo::table::internal::connect_lines");
90 
91  image1d<int> l(dim_size);
92  data::fill(l, -1);
93 
94  for_all_elements(i, aligned_lines)
95  opt::at(l, aligned_lines[i]) = aligned_lines[i];
96 
98  max_distance, -1);
99 
100  for_all_comps(i, boxes)
101  {
102  mln::util::couple<P,P> cp = central_sites(boxes[i], dim);
103  if (opt::at(l, cp.first()[dim]) != -1
104  && opt::at(l, cp.first()[dim]) < boxes[i].pmin()[dim])
105  boxes[i].pmin()[dim] = opt::at(l, cp.first()[dim]);
106  if (opt::at(l, cp.second()[dim]) != -1
107  && opt::at(l, cp.second()[dim]) > boxes[i].pmax()[dim])
108  boxes[i].pmax()[dim] = opt::at(l, cp.second()[dim]);
109  }
110 
111  }
112 
113 
114 # endif // ! MLN_INCLUDE_ONLY
115 
116 
117  } // end of namespace scribo::table::internal
118 
119  } // end of namespace scribo::table
120 
121 } // end of namespace scribo
122 
123 
124 #endif // ! SCRIBO_TABLE_INTERNAL_CONNECT_LINES_HH