$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
group_from_several_left_links.cc
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
#include <iostream>
28
29
#include <mln/core/image/image2d.hh>
30
#include <mln/core/alias/neighb2d.hh>
31
32
#include <mln/literal/colors.hh>
33
#include <mln/util/graph.hh>
34
35
#include <mln/labeling/colorize.hh>
36
37
#include <mln/value/rgb8.hh>
38
#include <mln/value/label_16.hh>
39
40
#include <mln/io/pbm/load.hh>
41
#include <mln/io/ppm/save.hh>
42
43
44
#include <scribo/primitive/extract/components.hh>
45
#include <scribo/primitive/group/apply.hh>
46
#include <scribo/primitive/link/with_several_left_links.hh>
47
#include <scribo/primitive/group/from_single_link.hh>
48
49
#include <scribo/debug/bboxes_image.hh>
50
#include <scribo/debug/linked_bboxes_image.hh>
51
#include <scribo/make/debug_filename.hh>
52
53
int
usage
(
const
char
*name)
54
{
55
std::cout <<
"Usage: "
<< name <<
" <input.pbm> "
<< std::endl;
56
return
1;
57
}
58
59
int
main(
int
argc,
char
* argv[])
60
{
61
using namespace
scribo;
62
using namespace
mln;
63
64
if
(argc < 1)
65
return
usage
(argv[0]);
66
67
scribo::make::internal::debug_filename_prefix =
"group_with_several_left_links"
;
68
69
image2d<bool>
input;
70
io::pbm::load
(input, argv[1]);
71
72
value::label_16 nbboxes;
73
typedef
image2d<value::label_16>
L;
74
component_set<L>
75
comps =
scribo::primitive::extract::components
(input,
c8
(), nbboxes);
76
77
{
78
std::cout <<
"* Left grouping"
<< std::endl;
79
object_links<L>
left_link
80
=
primitive::link::with_several_left_links
(comps, 30);
81
82
std::cout <<
"BEFORE - nbboxes = "
<< nbboxes << std::endl;
83
io::ppm::save
(
scribo::debug::linked_bboxes_image
(input,
84
left_link,
85
literal::red,
86
literal::cyan),
87
scribo::make::debug_filename
(
"left_links.ppm"
));
88
89
90
object_groups<L>
91
groups =
primitive::group::from_single_link
(left_link);
92
93
component_set<L>
grouped_comps =
primitive::group::apply
(groups);
94
std::cout <<
"AFTER - nbboxes = "
<< grouped_comps.
nelements
()
95
<< std::endl;
96
io::ppm::save
(
mln::labeling::colorize
(value::rgb8(),
97
grouped_comps.
labeled_image
(),
98
grouped_comps.
nelements
()),
99
scribo::make::debug_filename
(
"left_label_color.ppm"
));
100
io::ppm::save
(
scribo::debug::bboxes_image
(input, grouped_comps,
101
literal::red),
102
scribo::make::debug_filename
(
"left_bboxes.ppm"
));
103
}
104
105
}
scribo
src
primitive
group
group_from_several_left_links.cc
Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)