27 #ifndef SCRIBO_BINARIZATION_INTERNAL_WOLF_FUNCTOR_HH
28 # define SCRIBO_BINARIZATION_INTERNAL_WOLF_FUNCTOR_HH
34 # include <mln/core/image/image2d.hh>
35 # include <mln/core/alias/neighb2d.hh>
36 # include <mln/extension/fill.hh>
38 # include <scribo/binarization/internal/wolf_formula.hh>
40 # ifdef SCRIBO_LOCAL_THRESHOLD_DEBUG
41 # include <scribo/binarization/internal/local_threshold_debug.hh>
42 # endif // ! SCRIBO_LOCAL_THRESHOLD_DEBUG
60 typedef mln_value(I) V;
69 const mln_value(I)& global_min,
70 double global_max_stddev);
75 void exec(
double mean,
double stddev);
85 const mln_value(I)*
pi;
91 double global_max_stddev_;
98 #ifndef MLN_INCLUDE_ONLY
100 template <
typename I>
103 const mln_value(I)& global_min,
104 double global_max_stddev)
105 : input(
exact(input_)),
106 pi(&input(input.domain().pmin())),
108 global_min_(global_min),
109 global_max_stddev_(global_max_stddev)
111 mln_precondition(
exact(input).is_valid());
112 mln_precondition(K > 0.);
115 template <
typename I>
117 wolf_functor<I>::init()
121 next_line = 2 * input.border();
124 po = &output(output.domain().pmin());
127 template <
typename I>
129 wolf_functor<I>::exec(
double mean,
double stddev)
131 mln_assertion(input.border() == output.border());
133 double th = formula_(mean, stddev, K_,
134 global_max_stddev_, global_min_);
136 *po++ = (*
pi++ <= th);
138 # ifdef SCRIBO_LOCAL_THRESHOLD_DEBUG
140 unsigned index =
pi - input.buffer() - 1;
142 debug_mean.element(index) = mean * mean_debug_factor;
143 debug_stddev.element(index) = stddev * stddev_debug_factor;
144 debug_threshold.element(index) = th;
146 double alpha = K_ * (1 - stddev / R_);
147 debug_alpham.element(index) = alpha * mean * alpham_debug_factor;
148 debug_alphacond.element(index) = (stddev < (alpha * mean / 2.));
149 # endif // ! SCRIBO_LOCAL_THRESHOLD_DEBUG
153 template <
typename I>
155 wolf_functor<I>::end_of_row(
int)
161 template <
typename I>
163 wolf_functor<I>::finalize()
167 #endif // ! MLN_INCLUDE_ONLY
175 #endif // SCRIBO_BINARIZATION_INTERNAL_WOLF_FUNCTOR_HH