$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
sauvola_threshold.hh
1 // Copyright (C) 2009, 2010, 2011, 2013 EPITA Research and Development
2 // Laboratory (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 #ifndef SCRIBO_BINARIZATION_SAUVOLA_THRESHOLD_HH
28 # define SCRIBO_BINARIZATION_SAUVOLA_THRESHOLD_HH
29 
33 
35 
36 # include <algorithm>
37 # include <cmath>
38 
39 # include <mln/core/concept/image.hh>
40 # include <scribo/binarization/internal/local_threshold_core.hh>
41 # include <scribo/binarization/internal/sauvola_threshold_functor.hh>
42 
43 
44 
45 namespace scribo
46 {
47 
48  namespace binarization
49  {
50 
51  using namespace mln;
52 
63  template <typename I, typename J>
64  mln_ch_value(I, value::int_u8)
65  sauvola_threshold(const Image<I>& input, unsigned window_size,
66  double K);
67 
71  template <typename I>
72  mln_ch_value(I, value::int_u8)
73  sauvola_threshold(const Image<I>& input, unsigned window_size);
74 
75 
79  //
80  template <typename I>
81  mln_ch_value(I, value::int_u8)
82  sauvola_threshold(const Image<I>& input);
83 
84 
85 
86 # ifndef MLN_INCLUDE_ONLY
87 
88 
89  template <typename I>
90  mln_concrete(I)
91  sauvola_threshold(const Image<I>& input, unsigned window_size,
92  double K)
93  {
94  mln_trace("scribo::binarization::sauvola_threshold");
95 
96  mln_precondition(mln_site_(I)::dim == 2);
97  mln_precondition(exact(input).is_valid());
98 
99  internal::sauvola_threshold_functor<I> f(input, K, SCRIBO_DEFAULT_SAUVOLA_R);
100  internal::local_threshold_core(input, f, window_size);
101 
102  return f.output;
103  }
104 
105 
106  template <typename I>
107  inline
108  mln_ch_value(I, value::int_u8)
109  sauvola_threshold(const Image<I>& input, unsigned window_size)
110  {
111  return sauvola_threshold(input, window_size,
112  SCRIBO_DEFAULT_SAUVOLA_K);
113  }
114 
115 
116  template <typename I>
117  inline
118  mln_ch_value(I, value::int_u8)
119  sauvola_threshold(const Image<I>& input)
120  {
121  return sauvola_threshold(input, 11);
122  }
123 
124 
125 # endif // ! MLN_INCLUDE_ONLY
126 
127  } // end of namespace scribo::binarization
128 
129 } // end of namespace scribo
130 
131 
132 #endif // ! SCRIBO_BINARIZATION_SAUVOLA_THRESHOLD_HH