00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef OLENA_MORPHO_DILATION_HH
00029 # define OLENA_MORPHO_DILATION_HH
00030
00031 # include <oln/basics.hh>
00032 # include <oln/morpho/stat.hh>
00033 # include <oln/morpho/fast_morpho.hh>
00034 # include <mlc/cmp.hh>
00035
00036 namespace oln {
00037
00038 namespace morpho {
00039
00090 template<class I, class E>
00091 oln_concrete_type(I)
00092 dilation(const abstract::non_vectorial_image<I> &input,
00093 const abstract::struct_elt<E>& se)
00094 {
00095 mlc::eq<I::dim, E::dim>::ensure();
00096
00097 oln_concrete_type(I) output(input.size());
00098 input.border_adapt_copy(se.delta());
00099 oln_iter_type(I) p(input);
00100
00101 for_all (p)
00102 output[p] = morpho::max(input, p, se);
00103 return output;
00104 }
00105
00139 template <class I, class E>
00140 oln_concrete_type(I)
00141 n_dilation(const abstract::non_vectorial_image<I> & input,
00142 const abstract::struct_elt<E>& se,
00143 unsigned n)
00144 {
00145 precondition(n > 0);
00146 oln_concrete_type(I) output = input.clone();
00147 for (unsigned i = 0; i < n; ++i)
00148 {
00149 oln_concrete_type(I) work = dilation(output, se);
00150 output = work;
00151 }
00152 return output;
00153 }
00154
00155 namespace fast {
00156 template<class I, class E>
00157 oln_concrete_type(I)
00158 dilation(const abstract::non_vectorial_image<I>& input,
00159 const abstract::struct_elt<E>& se)
00160 {
00161 return fast_morpho<I, E, utils::histogram_max<oln_value_type(I)> >
00162 (input, se);
00163 }
00164 }
00165 }
00166
00167 }
00168
00169 #endif // ! OLENA_MORPHO_DILATION_HH