$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
niblack_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_NIBLACK_THRESHOLD_HH
28 # define SCRIBO_BINARIZATION_NIBLACK_THRESHOLD_HH
29 
33 
35 
36 # include <algorithm>
37 # include <cmath>
38 
39 # include <mln/core/concept/image.hh>
40 # include <scribo/binarization/internal/niblack_threshold_functor.hh>
41 # include <scribo/binarization/internal/local_threshold_core.hh>
42 
43 
44 namespace scribo
45 {
46 
47  namespace binarization
48  {
49 
50  using namespace mln;
51 
63  template <typename I, typename J>
64  mln_ch_value(I, value::int_u8)
65  niblack_threshold(const Image<I>& input, unsigned window_size,
66  double K);
67 
71  //
72  template <typename I>
73  mln_ch_value(I, value::int_u8)
74  niblack_threshold(const Image<I>& input, unsigned window_size);
75 
76 
80  //
81  template <typename I>
82  mln_ch_value(I, value::int_u8)
83  niblack_threshold(const Image<I>& input);
84 
85 
86 
87 # ifndef MLN_INCLUDE_ONLY
88 
89  template <typename I>
90  mln_ch_value(I, value::int_u8)
91  niblack_threshold(const Image<I>& input, unsigned window_size,
92  double K)
93  {
94  mln_trace("scribo::binarization::niblack_threshold");
95 
96  mln_precondition(mln_site_(I)::dim == 2);
97  mln_precondition(exact(input).is_valid());
98 
99  internal::niblack_threshold_functor<I> f(input, K);
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  niblack_threshold(const Image<I>& input, unsigned window_size)
110  {
111  return niblack_threshold(input, window_size,
112  SCRIBO_DEFAULT_NIBLACK_K);
113  }
114 
115 
116  template <typename I>
117  inline
118  mln_ch_value(I, value::int_u8)
119  niblack_threshold(const Image<I>& input)
120  {
121  return niblack_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_NIBLACK_THRESHOLD_HH