$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
labeling-compute.cc
1 #include <mln/core/image/image2d.hh>
2 #include <mln/core/alias/neighb2d.hh>
3 
4 #include <mln/make/image.hh>
5 
6 #include <mln/labeling/blobs.hh>
7 #include <mln/labeling/colorize.hh>
8 #include <mln/labeling/compute.hh>
9 
10 #include <mln/util/array.hh>
11 
12 #include <mln/accu/shape/bbox.hh>
13 
14 #include <mln/value/label_8.hh>
15 
16 #include <doc/tools/sample_utils.hh>
17 
18 int main()
19 {
20  using namespace mln;
21  using value::rgb8;
22  using value::label_8;
23 
24 
25  // \{
26  bool vals[6][5] = {
27  {0, 1, 1, 0, 0},
28  {0, 1, 1, 0, 0},
29  {0, 0, 0, 0, 0},
30  {1, 1, 0, 1, 0},
31  {1, 0, 1, 1, 1},
32  {1, 0, 0, 0, 0}
33  };
34  image2d<bool> ima = make::image(vals);
35  // \}
36  doc::pbmsave(ima, "labeling-compute");
37 
38  // \{
39  label_8 nlabels;
40  image2d<label_8> lbl = labeling::blobs(ima, c4(), nlabels);
41  // \}
42  doc::ppmsave(labeling::colorize(rgb8(), lbl, nlabels), "labeling-compute");
43 
44 
45  // \{
46  util::array<box2d> boxes =
48  lbl,
49  nlabels);
50  // \}
51 
52 
53  // \{
54  for (unsigned i = 1; i <= nlabels; ++i)
55  std::cout << boxes[i] << std::endl;
56  // \}
57 }