$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
extract_lines_with_features.hh
1 // Copyright (C) 2011, 2012 EPITA Research and Development Laboratory
2 // (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef SCRIBO_TEXT_EXTRACT_LINES_WITH_FEATURES_HH
28 # define SCRIBO_TEXT_EXTRACT_LINES_WITH_FEATURES_HH
29 
33 
34 
35 # include <mln/core/concept/image.hh>
36 
37 # include <scribo/text/extract_lines.hh>
38 
39 
40 namespace scribo
41 {
42 
43  namespace text
44  {
45 
46  using namespace mln;
47 
59  template <typename I, typename J, typename N>
60  line_set<mln_ch_value(I,scribo::def::lbl_type)>
62  const Image<J>& input_binary,
63  const Neighborhood<N>& nbh,
64  const mln_ch_value(I,bool)& separators);
65 
66 
70  template <typename I, typename J, typename N>
71  line_set<mln_ch_value(I,scribo::def::lbl_type)>
73  const Image<J>& input_binary,
74  const Neighborhood<N>& nbh);
75 
76 
77 # ifndef MLN_INCLUDE_ONLY
78 
79 
80  template <typename I, typename J, typename N>
81  line_set<mln_ch_value(I,scribo::def::lbl_type)>
83  const Image<J>& input_binary,
84  const Neighborhood<N>& nbh)
85  {
86  mln_ch_value(I,bool) seps;
87  return extract_lines_with_features(input, input_binary, nbh, seps);
88  }
89 
90 
91  template <typename I, typename J, typename N>
92  line_set<mln_ch_value(I,scribo::def::lbl_type)>
93  extract_lines_with_features(const Image<I>& input_,
94  const Image<J>& input_binary_,
95  const Neighborhood<N>& nbh_,
96  const mln_ch_value(I,bool)& separators)
97  {
98  mln_trace("scribo::text::extract_lines_with_features");
99 
100  const I& input = exact(input_);
101  const J& input_binary = exact(input_binary_);
102  const N& nbh = exact(nbh_);
103 
104  mln_precondition(input.is_valid());
105  mln_precondition(input_binary.is_valid());
106  mln_precondition(nbh.is_valid());
107 
109  typedef mln_ch_value(I,scribo::def::lbl_type) L;
110  scribo::def::lbl_type ncomps;
111  component_set<L>
112  comps = scribo::primitive::extract::components(input, input_binary,
113  nbh, ncomps);
114 
116  comps = scribo::filter::components_small(comps, 3);
117 
119  if (exact(separators).is_valid())
120  comps.add_separators(separators);
121 
122  line_set<mln_ch_value(I,scribo::def::lbl_type)>
123  lines = extract_lines(comps);
124 
125  return lines;
126  }
127 
128 
129 # endif // ! MLN_INCLUDE_ONLY
130 
131  } // end of namespace scribo::text
132 
133 } // end of namespace scribo
134 
135 #endif // ! SCRIBO_TEXT_EXTRACT_LINES_WITH_FEATURES_HH