$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
show_components_color.cc
1
// Copyright (C) 2010, 2011, 2013 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
#include <mln/core/image/image2d.hh>
19
#include <mln/core/alias/neighb2d.hh>
20
#include <mln/core/image/dmorph/image_if.hh>
21
#include <mln/pw/all.hh>
22
#include <mln/io/pbm/load.hh>
23
#include <mln/io/ppm/save.hh>
24
#include <mln/io/magick/load.hh>
25
#include <mln/value/int_u.hh>
26
#include <mln/literal/colors.hh>
27
#include <mln/draw/box.hh>
28
29
#include <scribo/core/component_set.hh>
30
#include <scribo/primitive/extract/components.hh>
31
32
int
main(
int
argc,
char
*argv[])
33
{
34
using namespace
mln;
35
using namespace
scribo;
36
37
if
(argc != 4)
38
{
39
std::cerr <<
"Usage : "
<< argv[0] <<
" input.* input.pbm out.ppm"
<< std::endl;
40
return
1;
41
}
42
43
typedef
mln::value::int_u<30>
V;
44
typedef
image2d<V>
L;
45
46
image2d<value::rgb8>
input;
47
io::magick::load
(input, argv[1]);
48
49
image2d<bool>
input_bin;
50
io::pbm::load
(input_bin, argv[2]);
51
52
V ncomponents;
53
component_set<L>
54
components
=
scribo::primitive::extract::components
(input, input_bin,
c8
(),
55
ncomponents);
56
57
image2d<value::rgb8>
output;
58
initialize
(output, input);
59
data::fill
(output,
literal::white
);
60
61
const
L& lbl =
components
.labeled_image();
62
for_all_comps(c,
components
)
63
if (
components
(c).is_valid())
64
{
65
data::fill
(((output |
components
(c).
bbox
()).rw()
66
| (
pw::value
(lbl) ==
pw::cst
(c))).rw(),
67
components
(c).features().color);
68
}
69
70
io::ppm::save
(output, argv[3]);
71
}
scribo
src
debug
show_components_color.cc
Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)