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
00029 #ifndef OLENA_MORPHO_GEODESIC_DILATION_HH
00030 # define OLENA_MORPHO_GEODESIC_DILATION_HH
00031
00032 # include <oln/basics.hh>
00033 # include <oln/morpho/stat.hh>
00034 # include <oln/morpho/dilation.hh>
00035 # include <oln/convert/conversion_ng_se.hh>
00036 # include <oln/level/compare.hh>
00037 # include <oln/arith/ops.hh>
00038
00039 # include <ntg/basics.hh>
00040
00041 # include <mlc/cmp.hh>
00042
00043 namespace oln {
00044 namespace morpho {
00045
00088 template<class I1, class I2, class N>
00089 oln_concrete_type(I1)
00090 geodesic_dilation(const abstract::non_vectorial_image<I1> & marker,
00091 const abstract::non_vectorial_image<I2> & mask,
00092 const abstract::neighborhood<N>& Ng)
00093 {
00094 mlc::eq<I1::dim, I2::dim>::ensure();
00095 mlc::eq<I1::dim, N::dim>::ensure();
00096 precondition(marker.size() == mask.size());
00097 precondition(level::is_greater_or_equal(mask, marker));
00098 return arith::min_with_ret<oln_concrete_type(I1)>
00099 (dilation(marker, convert::ng_to_cse(Ng)),
00100 mask);
00101 }
00102
00103 namespace sure {
00149 template<class I1, class I2, class N>
00150 oln_concrete_type(I1)
00151 geodesic_dilation(const abstract::non_vectorial_image<I1> & marker,
00152 const abstract::non_vectorial_image<I2> & mask,
00153 const abstract::neighborhood<N>& Ng)
00154 {
00155 mlc::eq<I1::dim, I2::dim>::ensure();
00156 mlc::eq<I1::dim, N::dim>::ensure();
00157 precondition(marker.size() == mask.size());
00158 precondition(level::is_greater_or_equal(mask, marker));
00159
00160 oln_concrete_type(I1) output(marker.size());
00161 marker.border_adapt_copy(Ng.delta());
00162 oln_iter_type(I1) p(marker);
00163 for_all (p)
00164 output[p] = std::min(morpho::max(marker, p, convert::ng_to_cse(Ng)), mask[p]);
00165 return output;
00166 }
00167
00168 }
00169 }
00170 }
00171
00172 #endif // OLENA_MORPHO_GEODESIC_DILATION_HH