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_GEOM_CHAMFER_HH
00028 # define MLN_GEOM_CHAMFER_HH
00029
00033
00034 # include <mln/canvas/chamfer.hh>
00035
00036
00037 namespace mln
00038 {
00039
00040 namespace geom
00041 {
00042
00044 template <typename I, typename W>
00045 mln_ch_value(I, unsigned)
00046 chamfer(const Image<I>& input_, const W& w_win_,
00047 unsigned max = mln_max(unsigned));
00048
00049
00050 # ifndef MLN_INCLUDE_ONLY
00051
00052 namespace impl
00053 {
00054
00055
00056
00057 template <typename I_, typename W_>
00058 struct chamfer_t
00059 {
00060 typedef I_ I;
00061 typedef mln_ch_value(I, unsigned) O;
00062 typedef W_ W;
00063 typedef mln_site(I_) P;
00064
00065
00066
00067 const I& input;
00068 const W& win;
00069
00070 O output;
00071 bool status;
00072 unsigned max;
00073
00074 void fill_output()
00075 {
00076 mln_piter(O) p(output.domain());
00077 for_all(p)
00078 {
00079 if (input(p))
00080 output(p) = 0u;
00081 else
00082 output(p) = max;
00083 }
00084 }
00085
00086 inline
00087 void init() { initialize(output, exact(input));
00088 fill_output();
00089
00090
00091
00092 }
00093 inline
00094 bool handles(const P& p) const { return input(p) == false; }
00095
00096
00097
00098 inline
00099 chamfer_t(const I_& input, const W_& win, unsigned max)
00100 : input (input),
00101 win (win),
00102 max (max)
00103 {}
00104 };
00105
00106 }
00107
00108
00109
00110
00111
00112 template <typename I, typename W>
00113 mln_ch_value(I, unsigned)
00114 chamfer(const Image<I>& input_, const W& w_win_,
00115 unsigned max)
00116 {
00117 trace::entering("mln::geom::chamfer");
00118
00119
00120 const I& input = exact(input_);
00121 const W& w_win = exact(w_win_);
00122
00123 typedef impl::chamfer_t<I, W> F;
00124
00125 F f(input, w_win, max);
00126 canvas::chamfer<F> run(f);
00127
00128 trace::exiting("mln::geom::chamfer");
00129 return f.output;
00130 }
00131
00132 #endif // ! MLN_INCLUDE_ONLY
00133
00134 }
00135
00136 }
00137
00138 #endif // ! MLN_GEOM_CHAMFER_HH