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_ATTRIBUTE_CLOSING_OPENING_MAP
00029 # define OLENA_MORPHO_ATTRIBUTE_CLOSING_OPENING_MAP
00030 # include <oln/morpho/attributes.hh>
00031 # include <oln/level/fill.hh>
00032 # include <oln/basics2d.hh>
00033 # include <ntg/int.hh>
00034 # include <oln/utils/histogram.hh>
00035 # include <oln/utils/special_points.hh>
00036 # include <oln/morpho/attributes.hh>
00037
00038 # include <iterator>
00039 # include <vector>
00040 # include <map>
00041 # include <algorithm>
00042 # include <utility>
00043
00044
00045 namespace oln
00046 {
00047 namespace morpho
00048 {
00052 namespace slow
00053 {
00064 template <class I, class D, class Env = morpho::env::NullEnv>
00065 struct f_tarjan_map
00066 {
00067 public:
00068 typedef abstract::non_vectorial_image<I> input_type;
00070
00071 typedef oln_concrete_type(I) img_type;
00073
00074 typedef oln_point_type(input_type) point_type;
00076
00077 typedef oln_value_type(input_type) value_type;
00079
00080 typedef typename mute<input_type, point_type>::ret parent_type;
00082
00083 typedef typename mute<input_type, bool>::ret is_proc_type;
00085 typedef attr_lambda_type(D) lambda_type;
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00109 template <class N>
00110 f_tarjan_map(bool is_closing,
00111 const input_type& input,
00112 const abstract::neighborhood<N>& ng,
00113 const lambda_type& lambda,
00114 const Env & env = Env());
00118 oln_concrete_type(I)
00119 res()
00120 {
00121 return output;
00122 }
00123 protected:
00124
00128 static const point_type
00129 inactive();
00130
00134 static const point_type
00135 active();
00136
00141 void
00142 make_set(const point_type& x);
00143
00149 void
00150 link(const point_type& x, const point_type& y);
00151
00156 point_type
00157 find_root(const point_type& x);
00158
00162 bool
00163 equiv(const point_type& x, const point_type& y) const;
00164
00165
00171 void
00172 do_union(const point_type& n, const point_type& p);
00173
00174 const bool is_closing;
00175 const input_type&input;
00176 lambda_type lambda;
00177 parent_type parent;
00178 is_proc_type is_proc;
00179 img_type output;
00180 std::map<point_type, D,
00181 oln::internal::default_less<point_type> > auxdata;
00183 Env env;
00184 };
00185
00186
00193 template <class D, class I, class N>
00194 oln_concrete_type(I)
00195 tarjan_map(bool is_closing,
00196 const abstract::non_vectorial_image<I>& input,
00197 const abstract::neighborhood<N>& ng,
00198 const attr_lambda_type(D)& lambda,
00199 const attr_env_type(D)& env)
00200 {
00201 oln::morpho::slow::f_tarjan_map<I, D, attr_env_type(D) > t(is_closing,
00202 input,
00203 ng,
00204 lambda,
00205 env);
00206 return t.res();
00207 }
00208
00209
00210
00211 # define xxx_opening_map_decl(T) \
00212 template <class I, class N> \
00213 oln_concrete_type(I) \
00214 T##_opening(const abstract::non_vectorial_image<I>& input, \
00215 const abstract::neighborhood<N>& ng, \
00216 const attr_lambda_type(attr::T##_type<>)& lambda) \
00217 { \
00218 return tarjan_map<attr::T##_type<>, I, N>(false, input, ng, lambda, \
00219 attr_env_type(attr::T##_type<>)()); \
00220 }
00221
00222
00223 # define xxx_opening_im_map_decl(T) \
00224 template <class I, class N> \
00225 oln_concrete_type(I) \
00226 T##_opening(const abstract::non_vectorial_image<I>& input, \
00227 const abstract::neighborhood<N>& ng, \
00228 const attr_lambda_type(attr::T##_type<I>)& lambda) \
00229 { \
00230 return tarjan_map<attr::T##_type<I>, I, N>(false, input, ng, lambda, \
00231 attr_env_type(attr::T##_type<I>)()); \
00232 }
00233
00234
00235
00236
00237 # define xxx_closing_map_decl(T) \
00238 template <class I, class N> \
00239 oln_concrete_type(I) \
00240 T##_closing(const abstract::non_vectorial_image<I>& input, \
00241 const abstract::neighborhood<N>& ng, \
00242 const attr_lambda_type(attr::T##_type<>)& lambda) \
00243 { \
00244 return tarjan_map<attr::T##_type<>, I, N>(true, input, ng, lambda, \
00245 attr_env_type(attr::T##_type<>)()); \
00246 }
00247
00248
00249 # define xxx_closing_im_map_decl(T) \
00250 template <class I, class N> \
00251 oln_concrete_type(I) \
00252 T##_closing(const abstract::non_vectorial_image<I>& input, \
00253 const abstract::neighborhood<N>& ng, \
00254 const attr_lambda_type(attr::T##_type<I>)& lambda) \
00255 { \
00256 return tarjan_map<attr::T##_type<I>, I, N>(true, input, ng, lambda, \
00257 attr_env_type(attr::T##_type<I>)());\
00258 }
00259
00284 xxx_closing_map_decl(card);
00285
00310 xxx_opening_map_decl(card);
00311
00337 xxx_closing_map_decl(integral);
00338
00364 xxx_opening_map_decl(integral);
00365
00390 xxx_opening_map_decl(height);
00391
00417 xxx_closing_map_decl(height);
00418
00419
00445 xxx_closing_map_decl(maxvalue);
00446
00472 xxx_opening_map_decl(maxvalue);
00473
00499 xxx_opening_map_decl(minvalue);
00500
00526 xxx_closing_map_decl(minvalue);
00527
00553 xxx_opening_im_map_decl(ball);
00554
00580 xxx_closing_im_map_decl(ball);
00581
00607 xxx_opening_im_map_decl(dist);
00608
00634 xxx_closing_im_map_decl(dist);
00635
00661 xxx_closing_im_map_decl(cube);
00662
00688 xxx_opening_im_map_decl(cube);
00689
00716 xxx_closing_im_map_decl(box);
00717
00744 xxx_opening_im_map_decl(box);
00745
00746
00747 }
00748 }
00749 }
00750
00751 #include "attribute_closing_opening_map.hxx"
00752
00753 #endif