Commit f61d9c41 authored by Baptiste Esteban's avatar Baptiste Esteban
Browse files

Add a test for the MToS function

parent 2fcf9e57
......@@ -65,6 +65,29 @@ static mln::image2d<std::uint16_t> depth_map_ref = {
{3, 2, 3, 1, 1, 1, 3, 2, 3}, //
};
static std::vector<int> parent_ref = {-1, 0, 1, 1, 3, 3, 3, 3, 3, 3, 1, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 21, 21, 10};
static mln::image2d<int> nodemap_ref = {
{0, 0, 0, 0, 2, 1, 1, 1, 4, 3, 3, 3, 6, 3, 3, 3, 7}, //
{0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3}, //
{0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3}, //
{0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3}, //
{23, 1, 1, 1, 1, 1, 1, 1, 8, 3, 3, 3, 3, 3, 3, 3, 9}, //
{21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3}, //
{21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3}, //
{21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3}, //
{22, 21, 21, 21, 21, 1, 1, 1, 1, 1, 1, 1, 11, 1, 1, 1, 3}, //
{21, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1}, //
{21, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1}, //
{21, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1}, //
{21, 10, 10, 10, 19, 10, 10, 10, 10, 10, 10, 10, 12, 10, 10, 10, 14}, //
{10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, //
{10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, //
{10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, //
{20, 10, 10, 10, 17, 10, 10, 10, 10, 10, 10, 10, 16, 10, 10, 10, 18}, //
};
TEST(Morpho, GoS)
{
mln::morpho::component_tree<> trees[3];
......@@ -112,34 +135,21 @@ TEST(Morpho, DepthMap)
TEST(Morpho, Satmaxtree)
{
std::vector<int> parent_ref = {-1, 0, 1, 1, 3, 3, 3, 3, 3, 3, 1, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 21, 21, 10};
mln::image2d<int> nodemap_ref = {
{0, 0, 0, 0, 2, 1, 1, 1, 4, 3, 3, 3, 6, 3, 3, 3, 7}, //
{0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3}, //
{0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3}, //
{0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3}, //
{23, 1, 1, 1, 1, 1, 1, 1, 8, 3, 3, 3, 3, 3, 3, 3, 9}, //
{21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3}, //
{21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3}, //
{21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3}, //
{22, 21, 21, 21, 21, 1, 1, 1, 1, 1, 1, 1, 11, 1, 1, 1, 3}, //
{21, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1}, //
{21, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1}, //
{21, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1}, //
{21, 10, 10, 10, 19, 10, 10, 10, 10, 10, 10, 10, 12, 10, 10, 10, 14}, //
{10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, //
{10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, //
{10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, //
{20, 10, 10, 10, 17, 10, 10, 10, 10, 10, 10, 10, 16, 10, 10, 10, 18}, //
};
// Test satmaxtree computation from depth map
auto [t, nm] = mln::morpho::details::satmaxtree(depth_map_ref, {0, 0});
ASSERT_EQ(t.parent.size(), parent_ref.size());
for (int i = 0; i < (int)parent_ref.size(); i++)
ASSERT_EQ(t.parent[i], parent_ref[i]);
ASSERT_IMAGES_EQ_EXP(nm, nodemap_ref);
}
TEST(Morpho, MToS)
{
auto [t, nm] = mln::morpho::mtos(input, {0, 0});
for (int i = 0; i < (int)parent_ref.size(); i++)
ASSERT_EQ(t.parent[i], parent_ref[i]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment