29 #ifndef TOOLS_CONNECTIVITY_NUMBERS_3D_HH
30 # define TOOLS_CONNECTIVITY_NUMBERS_3D_HH
40 # include <mln/core/image/dmorph/image_if.hh>
41 # include <mln/core/image/image3d.hh>
42 # include <mln/core/alias/neighb3d.hh>
43 # include <mln/value/int_u8.hh>
44 # include <mln/value/int_u32.hh>
46 # include <mln/labeling/blobs.hh>
47 # include <mln/data/fill.hh>
48 # include <mln/debug/println.hh>
119 typedef std::vector<conn_number_t> conn_numbers_t;
195 template <
typename F>
197 connectivity_numbers_3d(F f)
203 typedef mln_domain(I) B;
204 typedef mln_psite(I) P;
206 B b = make::
box3d(-1,-1,-1, 1,1,1);
210 const
unsigned dim = 3;
211 const
unsigned max_nneighbs = mlc_pow_int(3, dim) - 1;
212 const
unsigned nconfigs = mlc_pow_int(2, max_nneighbs);
214 conn_numbers_t numbers(nconfigs, 0);
227 mln_fwd_niter_(N) n(nbh, p);
256 typedef mln_psite_(I) P;
267 std::set<conn_number_t> s;
268 mln_niter_(N) n(nbh, p);
276 connectivity_numbers_3d__6_26()
278 return connectivity_numbers_3d(connectivity_number_3d__6_26_one);
302 connectivity_numbers_3d__26_6()
304 return connectivity_numbers_3d(connectivity_number_3d__26_6_one);
319 typedef mln_psite_(I) P;
329 mln_niter_(N) n(nbh, p);
337 connectivity_numbers_3d__6p_18()
339 return connectivity_numbers_3d(connectivity_number_3d__6p_18_one);
354 typedef mln_psite_(I) P;
364 mln_niter_(N) n(nbh, p);
372 connectivity_numbers_3d__18_6p()
374 return connectivity_numbers_3d(connectivity_number_3d__18_6p_one);
383 usage(
const std::string& program)
386 "usage: " << program <<
" <nbhs>" << std::endl <<
387 "where <nbhs> is one of these values:\n\n"
388 " `6_26' : 6-c foreground, 26-c background\n"
389 " `26_6' : 26-c foreground, 6-c background\n"
390 " `6p_18' : 6+-c foreground, 18-c background\n"
391 " `18_6p' : 18-c foreground, 6+-c background\n" << std::endl;
396 display_connectivity_numbers(
const conn_numbers_t& conn_numbers)
398 for (
size_t i = 0; i < conn_numbers.size(); ++i)
400 std::cout << std::setw(2) << conn_numbers[i] <<
", ";
401 if (! ((i + 1) % 4)) std::cout <<
" ";
402 if (! ((i + 1) % 16)) std::cout << std::endl;
403 if (! ((i + 1) % 64)) std::cout << std::endl;
407 #endif // ! TOOLS_CONNECTIVITY_NUMBERS_3D_HH