$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
separators.hh
1 // Copyright (C) 2010 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_PRIMITIVE_REMOVE_SEPARATORS_HH
27 # define SCRIBO_PRIMITIVE_REMOVE_SEPARATORS_HH
28 
32 
33 # include <mln/core/concept/image.hh>
34 
35 # include <mln/core/routine/duplicate.hh>
36 
37 # include <mln/core/image/dmorph/image_if.hh>
38 # include <mln/pw/all.hh>
39 
40 # include <mln/data/fill.hh>
41 
42 # include <mln/border/fill.hh>
43 # include <mln/border/resize.hh>
44 
45 
46 namespace scribo
47 {
48 
49  namespace primitive
50  {
51 
52  namespace remove
53  {
54 
55  using namespace mln;
56 
58 
68  template <typename I>
69  mln_concrete(I)
70  separators(const Image<I>& input, const Image<I>& separators);
71 
72 
73 
74 # ifndef MLN_INCLUDE_ONLY
75 
76 
77  template <typename I>
78  mln_concrete(I)
79  separators(const Image<I>& input_, const Image<I>& separators_)
80  {
81  mln_trace("scribo::primitive::remove::separators");
82 
83  const I& input = exact(input_);
84  const I& separators = exact(separators_);
85  mlc_is(mln_value(I), bool)::check();
86  mln_precondition(input.is_valid());
87  mln_precondition(separators.is_valid());
88 
89  mln_concrete(I) output = duplicate(input);
90 
91  border::resize(separators, output.border());
92  border::fill(separators, 0); // FIXME: we should rewrite image
93  // browsing below instead.
94 
95  typedef const mln_value(I)* sep_ptr_t;
96  sep_ptr_t
97  sep_ptr = separators.buffer(),
98  end_ptr = sep_ptr + input.nelements();
99  mln_value(I) *out_ptr = output.buffer();
100 
101  for (; sep_ptr < end_ptr; ++out_ptr)
102  if (*sep_ptr++)
103  *out_ptr = false;
104 
105  return output;
106  }
107 
108 # endif // ! MLN_INCLUDE_ONLY
109 
110  } // end of namespace scribo::primitive::remove
111 
112  } // end of namespace scribo::primitive
113 
114 } // end of namespace scribo
115 
116 #endif // ! SCRIBO_PRIMITIVE_REMOVE_SEPARATORS_HH