28 #include <mln/core/image/image2d.hh>
29 #include <mln/core/alias/neighb2d.hh>
30 #include <mln/io/pbm/load.hh>
32 #include <scribo/core/component_set.hh>
33 #include <scribo/core/def/lbl_type.hh>
34 #include <scribo/core/object_links.hh>
35 #include <scribo/core/object_groups.hh>
36 #include <scribo/primitive/extract/components.hh>
37 #include <scribo/primitive/link/with_single_left_link.hh>
39 #include "tests/data.hh"
44 using namespace scribo;
46 std::string img = SCRIBO_IMG_DIR
"/the_valleys.pbm";
48 static const unsigned comp_to_group_ref[] =
49 { 0, 1, 4, 2, 3, 2, 2, 4, 4, 2, 2, 2, 2 };
50 static const unsigned pixel_area_ref[] = { 0, 3, 973, 39, 426 };
51 static const box2d bbox_ref[] = {
59 static const unsigned comp_ids_count_ref[] = { 0, 1, 7, 1, 3 };
60 static const int comp_ids_ref[][7] = {
61 { 0, 0, 0, 0, 0, 0, 0 },
62 { 1, 0, 0, 0, 0, 0, 0 },
63 { 3, 9, 5, 6, 10, 11, 12 },
64 { 4, 0, 0, 0, 0, 0, 0 },
65 { 7, 2, 8, 0, 0, 0, 0 } };
77 = primitive::link::with_single_left_link(comps, 30);
81 mln_assertion(group.nelements() == 5);
82 mln_assertion(group.comp_to_group().nelements() == 13);
85 for (
unsigned i = 0; i < group.comp_to_group().nelements(); ++i)
86 mln_assertion(group.comp_to_group()[i] == comp_to_group_ref[i]);
89 for_all_groups(g, group)
91 mln_assertion(group(g).
id() == g);
92 mln_assertion(group(g).is_valid());
93 mln_assertion(group(g).pixel_area() == pixel_area_ref[g]);
94 mln_assertion(group(g).
bbox() == bbox_ref[g]);
95 mln_assertion(group(g).component_ids().
nelements()
96 == comp_ids_count_ref[g]);
98 for_all_elements(e, group(g).component_ids())
99 mln_assertion(group(g).component_ids()[e] == comp_ids_ref[g][e]);
103 for_all_comps(c, comps)
104 mln_assertion(group.group_of(c).
id() == comp_to_group_ref[c]);