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 # define xxx_opening_im_env_map_decl(T) \
00236 template <class I, class N> \
00237 oln_concrete_type(I) \
00238 T##_opening(const abstract::non_vectorial_image<I>& input, \
00239 const abstract::neighborhood<N>& ng, \
00240 const attr_lambda_type(attr::T##_type<I>)& lambda, \
00241 const attr_env_type(attr::T##_type<I>) &env) \
00242 { \
00243 return tarjan_map<attr::T##_type<I>, I, N>(false, input, ng, lambda, \
00244 env); \
00245 }
00246
00247
00248
00249
00250 # define xxx_closing_map_decl(T) \
00251 template <class I, class N> \
00252 oln_concrete_type(I) \
00253 T##_closing(const abstract::non_vectorial_image<I>& input, \
00254 const abstract::neighborhood<N>& ng, \
00255 const attr_lambda_type(attr::T##_type<>)& lambda) \
00256 { \
00257 return tarjan_map<attr::T##_type<>, I, N>(true, input, ng, lambda, \
00258 attr_env_type(attr::T##_type<>)()); \
00259 }
00260
00261
00262 # define xxx_closing_im_map_decl(T) \
00263 template <class I, class N> \
00264 oln_concrete_type(I) \
00265 T##_closing(const abstract::non_vectorial_image<I>& input, \
00266 const abstract::neighborhood<N>& ng, \
00267 const attr_lambda_type(attr::T##_type<I>)& lambda) \
00268 { \
00269 return tarjan_map<attr::T##_type<I>, I, N>(true, input, ng, lambda, \
00270 attr_env_type(attr::T##_type<I>)());\
00271 }
00272
00273 # define xxx_closing_im_env_map_decl(T) \
00274 template <class I, class N> \
00275 oln_concrete_type(I) \
00276 T##_closing(const abstract::non_vectorial_image<I>& input, \
00277 const abstract::neighborhood<N>& ng, \
00278 const attr_lambda_type(attr::T##_type<I>)& lambda, \
00279 const attr_env_type(attr::T##_type<I>) &env) \
00280 { \
00281 return tarjan_map<attr::T##_type<I>, I, N>(true, input, ng, lambda, \
00282 env); \
00283 }
00284
00309 xxx_closing_map_decl(card)
00310
00311
00335 xxx_opening_map_decl(card)
00336
00362 xxx_closing_map_decl(integral)
00363
00389 xxx_opening_map_decl(integral)
00390
00417 xxx_closing_im_env_map_decl(volume)
00418
00445 xxx_opening_im_env_map_decl(volume)
00446
00471 xxx_opening_map_decl(height)
00472
00498 xxx_closing_map_decl(height)
00499
00500
00526 xxx_closing_map_decl(maxvalue)
00527
00553 xxx_opening_map_decl(maxvalue)
00554
00580 xxx_opening_map_decl(minvalue)
00581
00607 xxx_closing_map_decl(minvalue)
00608
00634 xxx_opening_im_map_decl(ball)
00635
00661 xxx_closing_im_map_decl(ball)
00662
00688 xxx_opening_im_map_decl(dist)
00689
00715 xxx_closing_im_map_decl(dist)
00716
00742 xxx_closing_im_map_decl(cube)
00743
00769 xxx_opening_im_map_decl(cube)
00770
00797 xxx_closing_im_map_decl(box)
00798
00825 xxx_opening_im_map_decl(box)
00826
00827
00828 }
00829 }
00830 }
00831
00832 #include "attribute_closing_opening_map.hxx"
00833
00834 #endif