33 #include <mln/core/image/complex_image.hh>
34 #include <mln/core/image/complex_neighborhoods.hh>
36 #include <mln/core/site_set/p_set.hh>
38 #include <mln/value/label_16.hh>
40 #include <mln/labeling/regional_minima.hh>
41 #include <mln/morpho/closing/area.hh>
43 #include <mln/topo/is_n_face.hh>
44 #include <mln/topo/is_simple_cell.hh>
45 #include <mln/topo/detach.hh>
46 #include <mln/topo/skeleton/breadth_first_thinning.hh>
48 #include <mln/io/off/load.hh>
51 #include "save_bin_alt.hh"
55 main(
int argc,
char* argv[])
59 std::cerr <<
"usage: " << argv[0] <<
" input.off lambda output.off"
64 std::string input_filename = argv[1];
65 unsigned lambda = atoi(argv[2]);
66 std::string output_filename = argv[3];
75 static const unsigned D = ima_t::dim;
77 typedef mln_geom_(ima_t) G;
80 mln::io::off::load(input, input_filename);
84 mln::p_n_faces_fwd_piter<D, G> v(input.domain(), 0);
86 input(v) = mln_max(
float);
87 mln::p_n_faces_fwd_piter<D, G> e(input.domain(), 1);
89 input(e) = mln_max(
float);
96 typedef mln::complex_lower_dim_connected_n_face_neighborhood<D, G> nbh_t;
99 ima_t closed_input = mln::morpho::closing::area(input, nbh, lambda);
105 typedef mln::value::label_16 label_t;
111 typedef mln_ch_value_(ima_t, label_t) label_ima_t;
113 mln::labeling::regional_minima(closed_input, nbh, nminima);
115 typedef mln::complex_higher_neighborhood<D, G> higher_nbh_t;
116 higher_nbh_t higher_nbh;
120 mln_niter_(higher_nbh_t) adj_t(higher_nbh, e);
125 if (minima(adj_t) == mln::literal::zero)
136 ref_adj_minimum = minima(adj_t);
140 mln_assertion(minima(adj_t) == ref_adj_minimum);
142 minima(e) = ref_adj_minimum;
146 mln_niter_(higher_nbh_t) adj_e(higher_nbh, v);
151 if (minima(adj_e) == mln::literal::zero)
162 ref_adj_minimum = minima(adj_e);
166 mln_assertion(minima(adj_e) == ref_adj_minimum);
168 minima(v) = ref_adj_minimum;
175 typedef mln_ch_value_(ima_t,
bool) bin_ima_t;
176 bin_ima_t surface(minima.domain());
177 mln::
data::fill(surface, true);
180 mln_piter_(bin_ima_t) f(minima.domain());
182 if (minima(f) != mln::literal::zero)
189 mln::topo::is_simple_cell<bin_ima_t> is_simple_p;
198 mln::topo::is_n_face<bin_ima_t::dim> constraint_p;
200 mln::topo::skeleton::breadth_first_thinning(surface, nbh,
202 mln::topo::detach<D, G>,