$extrastylesheet
Olena
User documentation 2.1
An Image Processing Platform
Scribo
Modules
Namespaces
Classes
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
extract.hh
1
// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
2
// Laboratory (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_TABLE_EXTRACT_HH
28
# define SCRIBO_TABLE_EXTRACT_HH
29
34
35
# include <mln/core/concept/image.hh>
36
# include <mln/util/couple.hh>
37
# include <mln/util/array.hh>
38
39
# include <mln/io/ppm/all.hh>
40
# include <mln/labeling/colorize.hh>
41
42
# include <scribo/table/rebuild.hh>
43
# include <scribo/table/erase.hh>
44
# include <scribo/primitive/extract/lines_h_pattern.hh>
45
# include <scribo/primitive/extract/lines_v_pattern.hh>
46
# include <scribo/primitive/extract/components.hh>
47
48
namespace
scribo
49
{
50
51
namespace
table
52
{
53
using namespace
mln;
54
57
/*
58
** \param[in] input_ A binary image.
59
** \param[in,out] ncells The number of cells.
60
**
61
** \return a couple. The first element is an image containing the
62
** cells components. The second element is a couple of vertical and
63
** horizontal table lines.
64
*/
65
template
<
typename
I,
typename
V>
66
mln::util::couple
<
mln_ch_value
(I,V),
67
mln::util::couple<mln::util::array<box<mln_site(I)>
>,
68
mln::util::array<box<mln_site(I)>
> > >
69
extract
(
const
Image<I>
& input_, V& ncells);
70
71
72
# ifndef MLN_INCLUDE_ONLY
73
74
template
<
typename
I,
typename
V>
75
inline
76
mln::util::couple
<
mln_ch_value
(I,V),
77
mln::util::couple<mln::util::array<box<mln_site(I)>
>,
78
mln::util::array<box<mln_site(I)>
> > >
79
extract
(
const
Image<I>
& input_, V& ncells)
80
{
81
mln_trace(
"scribo::table::extract"
);
82
83
const
I& input =
exact
(input_);
84
mln_precondition(input.is_valid());
85
mlc_equal(mln_value(I),
bool
)::check();
86
87
image2d<bool>
88
bhlines =
scribo::primitive::extract::lines_h_pattern
(input, 51, 3),
89
bvlines =
scribo::primitive::extract::lines_v_pattern
(input, 51, 3);
90
91
V nhlines, nvlines;
92
component_set<mln_ch_value(I,V)>
93
hlines =
scribo::primitive::extract::components
(bhlines,
c8
(),
94
nhlines),
95
vlines =
scribo::primitive::extract::components
(bvlines,
c8
(),
96
nvlines);
97
98
typedef
mln::util::couple
<
mln_ch_value
(I,V),
99
mln::util::couple<mln::util::array<box<mln_site(I)>
>,
100
mln::util::array<box<mln_site(I)>
> > >
101
tables_t;
102
tables_t tables
103
=
scribo::table::rebuild
(input,
104
vlines, hlines, 30, ncells);
105
106
return
tables;
107
}
108
109
# endif // ! MLN_INCLUDE_ONLY
110
111
}
// end of namespace scribo::table
112
113
}
// end of namespace scribo
114
115
#endif // ! SCRIBO_TABLE_EXTRACT_HH
scribo
scribo
table
extract.hh
Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)