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 #ifndef MLN_LABELING_FLAT_ZONES_HH
00028 # define MLN_LABELING_FLAT_ZONES_HH
00029
00033
00034 # include <mln/core/concept/image.hh>
00035 # include <mln/core/concept/neighborhood.hh>
00036 # include <mln/canvas/labeling/video.hh>
00037
00038
00039 namespace mln
00040 {
00041
00042 namespace labeling
00043 {
00044
00052 template <typename I, typename N, typename L>
00053 mln_ch_value(I, L)
00054 flat_zones(const Image<I>& input, const Neighborhood<N>& nbh, L& nlabels);
00055
00056
00057
00058 # ifndef MLN_INCLUDE_ONLY
00059
00060 namespace impl
00061 {
00062
00063
00064
00065 template <typename I>
00066 struct flat_zones_functor
00067 {
00068 const I& input;
00069
00070
00071
00072 typedef mln_psite(I) P;
00073
00074 void init() {}
00075 bool handles(const P&) const { return true; }
00076 bool equiv(const P& n, const P& p) const { return input(n) ==
00077 input(p); }
00078 bool labels(const P&) const { return true; }
00079 void do_no_union(const P&, const P&) {}
00080 void init_attr(const P&) {}
00081 void merge_attr(const P&, const P&) {}
00082
00083
00084
00085 void init_() {}
00086 bool handles_(unsigned) const { return true; }
00087 bool equiv_(unsigned n, unsigned p) const { return input.element(n) ==
00088 input.element(p); }
00089 bool labels_(unsigned) const { return true; }
00090 void do_no_union_(unsigned, unsigned) {}
00091 void init_attr_(unsigned) {}
00092 void merge_attr_(unsigned, unsigned) {}
00093
00094
00095
00096 flat_zones_functor(const I& input)
00097 : input(input)
00098 {}
00099 };
00100
00101
00102 }
00103
00104
00105
00106
00107
00108 template <typename I, typename N, typename L>
00109 mln_ch_value(I, L)
00110 flat_zones(const Image<I>& input_, const Neighborhood<N>& nbh_,
00111 L& nlabels)
00112 {
00113 trace::entering("labeling::flat_zones");
00114
00115 const I& input = exact(input_);
00116 const N& nbh = exact(nbh_);
00117 mln_precondition(input.is_valid());
00118
00119
00120 typedef impl::flat_zones_functor<I> F;
00121 F f(input);
00122 mln_ch_value(I, L)
00123 output = canvas::labeling::video(input, nbh, nlabels, f);
00124
00125 trace::exiting("labeling::flat_zones");
00126 return output;
00127 }
00128
00129 # endif // ! MLN_INCLUDE_ONLY
00130
00131 }
00132
00133 }
00134
00135
00136 #endif // ! MLN_LABELING_FLAT_ZONES_HH