$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
morpho.cc
1
// Copyright (C) 2009, 2013, 2014 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
#include <mln/core/image/image2d.hh>
28
#include <mln/core/alias/neighb2d.hh>
29
30
#include <mln/literal/colors.hh>
31
32
#include <mln/value/label_16.hh>
33
#include <mln/value/int_u16.hh>
34
35
#include <mln/labeling/wrap.hh>
36
#include <mln/labeling/colorize.hh>
37
#include <mln/labeling/blobs.hh>
38
39
#include <mln/io/pbm/load.hh>
40
#include <mln/io/pgm/save.hh>
41
#include <mln/io/ppm/save.hh>
42
43
#include <mln/transform/distance_and_influence_zone_geodesic.hh>
44
45
#include <mln/win/hline2d.hh>
46
#include <mln/win/disk2d.hh>
47
48
#include <mln/morpho/watershed/flooding.hh>
49
#include <mln/morpho/watershed/superpose.hh>
50
#include <mln/morpho/closing/structural.hh>
51
52
#include <scribo/make/debug_filename.hh>
53
54
55
int
main(
int
argc,
char
*argv[])
56
{
57
using namespace
mln;
58
59
using
value::int_u16;
60
using
value::label_16;
61
using
value::label_8;
62
using
value::rgb8;
63
64
if
(argc != 2)
65
{
66
std::cout <<
"Usage: "
<< argv[0] <<
" <input.pbm>"
<< std::endl;
67
return
1;
68
}
69
70
image2d<bool>
input;
71
io::pbm::load
(input, argv[1]);
72
73
scribo::make::internal::debug_filename_prefix =
"morpho"
;
74
75
label_16 nlabels;
76
image2d<label_16>
lbl =
labeling::blobs
(input,
c8
(), nlabels);
77
78
typedef
util::couple< image2d<unsigned>,
image2d<label_16>
> res_t;
79
res_t res =
80
transform::distance_and_influence_zone_geodesic
(lbl,
81
c8
(),
82
mln_max(
unsigned
));
83
84
io::pgm::save
(
labeling::wrap
(res.first()),
"dmap.pgm"
);
85
io::ppm::save
(
labeling::colorize
(rgb8(), res.second(), nlabels),
"iz.ppm"
);
86
87
image2d<unsigned>
& dmap = res.first();
88
{
89
image2d<unsigned>
clo =
morpho::closing::structural
(dmap,
win::hline2d
(51));
90
io::pgm::save
(clo,
scribo::make::debug_filename
(
"clo_line_51.pgm"
));
91
label_16 nlabels;
92
image2d<label_16>
wsd =
morpho::watershed::flooding
(clo,
c8
(), nlabels);
93
94
io::ppm::save
(
morpho::watershed::superpose
(input, wsd),
95
scribo::make::debug_filename
(
"wsd_line_51.ppm"
));
96
}
97
98
{
99
image2d<unsigned>
clo =
morpho::closing::structural
(dmap,
win::rectangle2d
(11, 101));
100
io::pgm::save
(clo,
scribo::make::debug_filename
(
"clo_rectangle_11_101.pgm"
));
101
label_16 nlabels;
102
image2d<label_16>
wsd =
morpho::watershed::flooding
(clo,
c8
(), nlabels);
103
104
io::ppm::save
(
morpho::watershed::superpose
(input, wsd),
105
scribo::make::debug_filename
(
"wsd_rectangle_11_101.ppm"
));
106
}
107
108
{
109
image2d<unsigned>
clo =
morpho::closing::structural
(dmap,
win::disk2d
(51));
110
io::pgm::save
(clo,
scribo::make::debug_filename
(
"clo_disk_51.pgm"
));
111
label_16 nlabels;
112
image2d<label_16>
wsd =
morpho::watershed::flooding
(clo,
c8
(), nlabels);
113
114
io::ppm::save
(
morpho::watershed::superpose
(input, wsd),
115
scribo::make::debug_filename
(
"wsd_disk_51.ppm"
));
116
}
117
118
}
scribo
src
misc
morpho.cc
Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)