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 #ifndef MLN_MAKE_EDGE_IMAGE_HH
00027 # define MLN_MAKE_EDGE_IMAGE_HH
00028
00032
00033 # include <mln/core/image/edge_image.hh>
00034 # include <mln/core/image/vertex_image.hh>
00035 # include <mln/core/concept/function.hh>
00036 # include <mln/util/internal/id2element.hh>
00037 # include <mln/data/fill.hh>
00038
00039
00040 namespace mln
00041 {
00042
00043 namespace make
00044 {
00045
00046
00053
00054 template <typename V, typename G>
00055 mln::edge_image<void,V,G>
00056 edge_image(const Graph<G>& g, const fun::i2v::array<V>& fv);
00057
00064
00065 template <typename FV, typename G>
00066 mln::edge_image<void, mln_result(FV), G>
00067 edge_image(const Graph<G>& g, const Function_v2v<FV>& fv);
00068
00069
00077
00078 template <typename FP, typename FV, typename G>
00079 mln::edge_image<mln_result(FP),mln_result(FV),G>
00080 edge_image(const Graph<G>& g_,
00081 const Function_v2v<FP>& fp,
00082 const Function_v2v<FV>& fv);
00083
00084
00085
00094
00095 template <typename P, typename V, typename G, typename FP, typename FV>
00096 mln::edge_image<mln_result(FP),mln_result(FV),G>
00097 edge_image(const mln::vertex_image<P,V,G>& v_ima_,
00098 const p_edges<G,FP> pe,
00099 const Function_vv2v<FV>& fv_);
00100
00101
00102
00111
00112 template <typename P, typename V, typename G, typename FV>
00113 mln::edge_image<void,mln_result(FV),G>
00114 edge_image(const mln::vertex_image<P,V,G>& v_ima_,
00115 const Function_vv2v<FV>& fv_);
00116
00117
00126
00127 template <typename P, typename V, typename G, typename F>
00128 mln::edge_image<void,bool,G>
00129 edge_image(const mln::vertex_image<P,V,G>& v_ima_,
00130 const Function_v2b<F>& fv_);
00131
00132
00133 # ifndef MLN_INCLUDE_ONLY
00134
00135
00136
00137 template <typename V, typename G>
00138 inline
00139 mln::edge_image<void,V,G>
00140 edge_image(const Graph<G>& g, const fun::i2v::array<V>& fv)
00141 {
00142 trace::entering("make::edge_image");
00143 mln_precondition(exact(g).is_valid());
00144
00145 p_vertices<G> pv(g);
00146 mln::edge_image<void,V,G> ima(pv, fv);
00147
00148 trace::exiting("make::edge_image");
00149 return ima;
00150 }
00151
00152 template <typename FV, typename G>
00153 mln::edge_image<void,mln_result(FV),G>
00154 edge_image(const Graph<G>& g_,
00155 const Function_v2v<FV>& fv)
00156 {
00157 trace::entering("make::edge_image");
00158 const G& g = exact(g_);
00159 const FV& f = exact(fv);
00160 mln_precondition(g.is_valid());
00161
00162 p_edges<G> pe(g);
00163 typedef mln::edge_image<void,mln_result(FV),G> ima_t;
00164 ima_t ima(pe);
00165
00166 mln_piter(ima_t) e(ima.domain());
00167 for_all(e)
00168 ima(e) = f(e.id());
00169
00170 trace::exiting("make::edge_image");
00171 return ima;
00172 }
00173
00174
00175 template <typename FP, typename FV, typename G>
00176 inline
00177 mln::edge_image<mln_result(FP),mln_result(FV),G>
00178 edge_image(const Graph<G>& g_,
00179 const Function_v2v<FP>& fp,
00180 const Function_v2v<FV>& fv)
00181 {
00182 trace::entering("make::edge_image");
00183 const G& g = exact(g_);
00184 mln_precondition(g.is_valid());
00185
00186 p_vertices<G,FP> pv(g,fp);
00187 mln::edge_image<mln_result(FP),mln_result(FV),G> ima(pv, fv);
00188
00189 trace::exiting("make::edge_image");
00190 return ima;
00191 }
00192
00193
00194
00195 template <typename P, typename V, typename G, typename FP, typename FV>
00196 inline
00197 mln::edge_image<mln_result(FP),mln_result(FV),G>
00198 edge_image(const mln::vertex_image<P,V,G>& v_ima_,
00199 const p_edges<G,FP> pe,
00200 const Function_vv2v<FV>& fv_)
00201 {
00202 trace::entering("make::edge_image");
00203
00204 const FV& fv = exact(fv_);
00205 const mln::vertex_image<P,V,G>& v_ima = exact(v_ima_);
00206 mln_precondition(v_ima.is_valid());
00207
00208 typedef mln::edge_image<mln_result(FP),mln_result(FV),G> edge_ima_t;
00209 edge_ima_t ima_e(pe);
00210
00211 mln_piter(edge_ima_t) e(ima_e.domain());
00212 for_all(e)
00213 ima_e(e) = fv(e.element().v1(), e.element().v2());
00214
00215 trace::exiting("make::edge_image");
00216 return ima_e;
00217 }
00218
00219
00220
00221 template <typename P, typename V, typename G, typename FV>
00222 inline
00223 mln::edge_image<void,mln_result(FV),G>
00224 edge_image(const mln::vertex_image<P,V,G>& v_ima_,
00225 const Function_vv2v<FV>& fv_)
00226 {
00227 trace::entering("make::edge_image");
00228
00229 const FV& fv = exact(fv_);
00230 const mln::vertex_image<P,V,G>& v_ima = exact(v_ima_);
00231 mln_precondition(v_ima.is_valid());
00232
00233 p_edges<G> pe(v_ima.domain().graph());
00234 typedef mln::edge_image<void,mln_result(FV),G> edge_ima_t;
00235 edge_ima_t ima_e(pe);
00236
00237 mln_piter(edge_ima_t) e(ima_e.domain());
00238 for_all(e)
00239 ima_e(e) = fv(v_ima(e.element().v1()), v_ima(e.element().v2()));
00240
00241 trace::exiting("make::edge_image");
00242 return ima_e;
00243 }
00244
00245
00246 template <typename P, typename V, typename G, typename F>
00247 inline
00248 mln::edge_image<void,bool,G>
00249 edge_image(const mln::vertex_image<P,V,G>& v_ima_,
00250 const Function_v2b<F>& fv_)
00251 {
00252 trace::entering("make::edge_image");
00253
00254 const F& fv = exact(fv_);
00255 typedef mln::vertex_image<P,V,G> v_ima_t;
00256 const v_ima_t& v_ima = exact(v_ima_);
00257 mln_precondition(v_ima.is_valid());
00258
00259
00260 p_edges<G> pe(v_ima.domain().graph());
00261 typedef mln::edge_image<void,bool,G> edge_ima_t;
00262 edge_ima_t ima_e(pe);
00263 data::fill(ima_e, true);
00264
00265 mln_piter(v_ima_t) p(v_ima.domain());
00266 for_all(p)
00267 if (!fv(v_ima(p)))
00268 {
00269 typename v_ima_t::edge_win_t win;
00270 mln_qiter(v_ima_t::edge_win_t) q(win, p);
00271 for_all(q)
00272 std::cout << q << std::endl;
00273
00274 }
00275
00276 trace::exiting("make::edge_image");
00277 return ima_e;
00278 }
00279
00280
00281
00282 # endif // ! MLN_INCLUDE_ONLY
00283
00284
00285 }
00286
00287 }
00288
00289 #endif // ! MLN_MAKE_EDGE_IMAGE_HH