$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
compute_skeleton.hh
1 // Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #ifndef SCRIBO_ESTIM_INTERNAL_COMPUTE_SKELETON_HH
27 # define SCRIBO_ESTIM_INTERNAL_COMPUTE_SKELETON_HH
28 
32 
33 
34 # include <mln/core/image/image2d.hh>
35 # include <mln/core/alias/neighb2d.hh>
36 # include <mln/topo/skeleton/crest.hh>
37 # include <mln/topo/skeleton/is_simple_point.hh>
38 # include <mln/transform/distance_front.hh>
39 # include <mln/logical/not.hh>
40 # include <mln/make/w_window2d_int.hh>
41 # include <mln/make/dual_neighb.hh>
42 # include <mln/value/int_u8.hh>
43 # include <mln/arith/revert.hh>
44 # include <mln/morpho/skeleton_constrained.hh>
45 # include <mln/core/routine/extend.hh>
46 # include <mln/labeling/blobs.hh>
47 # include <mln/accu/stat/mean.hh>
48 # include <mln/value/rgb8.hh>
49 
50 
51 namespace scribo
52 {
53 
54  namespace estim
55  {
56 
57  namespace internal
58  {
59  using namespace mln;
60 
61 
63  //
64  template <typename I>
65  mln_concrete(I)
66  compute_skeleton(const Image<I>& input);
67 
68 
69 # ifndef MLN_INCLUDE_ONLY
70 
71  template <typename I>
72  mln_concrete(I)
73  compute_skeleton(const Image<I>& input_)
74  {
75  mln_trace("scribo::estim::internal::compute_skeleton");
76 
77  const I& input = exact(input_);
78  mlc_is(mln_value(I), bool)::check();
79  mln_precondition(input.is_valid());
80 
81  int psi = 7;
82  int vals[] = { 0, 9, 0, 9, 0,
83  9, 6, 4, 6, 9,
84  0, 4, 0, 4, 0,
85  9, 6, 4, 6, 9,
86  0, 9, 0, 9, 0 };
87 
88  mln_ch_value(I,value::int_u8)
89  dist = transform::distance_front(logical::not_(input), c8(),
90  mln::make::w_window2d_int(vals),
91  mln_max(value::int_u8));
92 
93  mln_ch_value(I,value::int_u8) dist_map = arith::revert(dist);
94  mln_concrete(I) K = topo::skeleton::crest(input, dist, c8(), psi);
95 
96  typedef
97  neighb<win::multiple_size<2u, window2d, pw::value_<I> > >
98  nbh_t;
99  nbh_t nbh = mln::make::dual_neighb(input, c8(), c4());
100 
101  mln_concrete(I) skel =
102  morpho::skeleton_constrained(input, nbh,
103  topo::skeleton::is_simple_point<nbh_t>(nbh),
104  K, dist_map);
105 
106  return skel;
107  }
108 
109 # endif // ! MLN_INCLUDE_ONLY
110 
111  } // end of namespace scribo::estim::internal
112 
113  } // end of namespace scribo::estim
114 
115 } // end of namespace scribo
116 
117 #endif // ! SCRIBO_ESTIM_INTERNAL_COMPUTE_SKELETON_HH