$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
show_components_bboxes.cc
1 // Copyright (C) 2010, 2011 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 #include <mln/core/image/image2d.hh>
19 #include <mln/core/alias/neighb2d.hh>
20 #include <mln/io/pbm/all.hh>
21 #include <mln/value/int_u.hh>
22 #include <mln/literal/colors.hh>
23 #include <mln/draw/box.hh>
24 
25 #include <scribo/core/component_set.hh>
26 #include <scribo/primitive/extract/components.hh>
27 
28 int main(int argc, char *argv[])
29 {
30  using namespace mln;
31  using namespace scribo;
32 
33  if (argc != 3)
34  {
35  std::cerr << "Usage : " << argv[0] << " input.pbm out.pbm" << std::endl;
36  return 1;
37  }
38 
39  typedef mln::value::int_u<30> V;
40  typedef image2d<V> L;
41 
42  image2d<bool> input;
43  io::pbm::load(input, argv[1]);
44 
45  V ncomponents;
48  ncomponents);
49 
50  image2d<bool> output;
51  initialize(output, input);
52  data::fill(output, false);
53 
54  for_all_comps(c, components)
55  if (components(c).is_valid())
56  mln::draw::box(output, components(c).bbox(), true);
57 
58  io::pbm::save(output, argv[2]);
59 }