Commit 9ee51649 authored by Baptiste Esteban's avatar Baptiste Esteban
Browse files

Add test for the depth map computation

parent bf7a0266
Pipeline #30561 passed with stages
in 18 minutes and 45 seconds
...@@ -5,55 +5,68 @@ ...@@ -5,55 +5,68 @@
#include <mln/morpho/private/trees_fusion.hpp> #include <mln/morpho/private/trees_fusion.hpp>
#include <fixtures/ImageCompare/image_compare.hpp>
#include <gtest/gtest.h> #include <gtest/gtest.h>
static std::vector<std::set<int>> graph_ref = { //
{}, //
{0}, //
{0, 1}, //
{0, 1, 14}, //
{0, 1, 20}, //
{0, 1, 24}, //
{0, 1, 14}, //
{0, 1, 14}, //
{0, 7, 19}, //
{0, 1, 22}, //
{0, 14}, //
{0, 10, 14}, //
{0, 11, 15}, //
{0, 16}, //
{0}, //
{0, 10, 14}, //
{0, 14}, //
{0, 16, 29}, //
{0, 16}, //
{0, 1, 14}, //
{0, 1, 14}, //
{0, 7, 14}, //
{0, 1, 14}, //
{0, 7, 22}, //
{0, 1, 14}, //
{6, 24, 28}, //
{0, 10, 15}, //
{0, 1, 20}, //
{0, 1, 14}, //
{0, 14}, //
{0, 1, 19}};
static std::vector<std::vector<int>> tree_to_graph_ref = {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13},
{0, 2, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25},
{0, 26, 27, 28, 29, 30}};
static mln::image2d<mln::rgb8> input = {
{{255, 146, 0}, {31, 174, 0}, {45, 0, 255}, {255, 75, 0}, {31, 174, 0}}, //
{{45, 0, 255}, {255, 75, 0}, {3, 0, 0}, {45, 0, 255}, {255, 255, 255}}, //
{{3, 0, 0}, {31, 174, 0}, {255, 75, 0}, {31, 174, 0}, {255, 75, 0}}, //
{{31, 174, 0}, {255, 255, 255}, {45, 0, 255}, {3, 0, 0}, {45, 0, 255}}, //
{{255, 75, 0}, {31, 174, 0}, {255, 75, 0}, {31, 174, 0}, {255, 146, 0}}, //
};
static mln::image2d<std::uint16_t> depth_map_ref = {
{0, 0, 2, 1, 3, 1, 2, 1, 3}, //
{0, 0, 0, 0, 2, 1, 1, 1, 2}, //
{4, 1, 1, 1, 3, 2, 2, 2, 3}, //
{3, 1, 1, 1, 1, 1, 1, 1, 2}, //
{4, 3, 3, 1, 1, 1, 3, 1, 2}, //
{3, 1, 2, 1, 1, 1, 2, 1, 1}, //
{3, 2, 3, 2, 2, 2, 3, 2, 3}, //
{2, 2, 2, 1, 1, 1, 2, 1, 1}, //
{3, 2, 3, 1, 1, 1, 3, 2, 3}, //
};
TEST(Morpho, GoS) TEST(Morpho, GoS)
{ {
mln::image2d<mln::rgb8> input = {
{{255, 146, 0}, {31, 174, 0}, {45, 0, 255}, {255, 75, 0}, {31, 174, 0}}, //
{{45, 0, 255}, {255, 75, 0}, {3, 0, 0}, {45, 0, 255}, {255, 255, 255}}, //
{{3, 0, 0}, {31, 174, 0}, {255, 75, 0}, {31, 174, 0}, {255, 75, 0}}, //
{{31, 174, 0}, {255, 255, 255}, {45, 0, 255}, {3, 0, 0}, {45, 0, 255}}, //
{{255, 75, 0}, {31, 174, 0}, {255, 75, 0}, {31, 174, 0}, {255, 146, 0}}, //
};
std::vector<std::set<int>> graph_ref = { //
{}, // 0
{0}, // 1
{0, 1}, // 2
{0, 1, 14}, // 3
{0, 1, 20}, // 4
{0, 1, 24}, // 5
{0, 1, 14}, // 6
{0, 1, 14}, // 7
{0, 7, 19}, // 8
{0, 1, 22}, // 9
{0, 14}, // 10
{0, 10, 14}, // 11
{0, 11, 15}, // 12
{0, 16}, // 13
{0}, // 14
{0, 10, 14}, // 15
{0, 14}, // 16
{0, 16, 29}, // 17
{0, 16}, // 18
{0, 1, 14}, // 19
{0, 1, 14}, // 20
{0, 7, 14}, // 21
{0, 1, 14}, // 22
{0, 7, 22}, // 23
{0, 1, 14}, // 24
{6, 24, 28}, // 25
{0, 10, 15}, // 26
{0, 1, 20}, // 27
{0, 1, 14}, // 28
{0, 14}, // 29
{0, 1, 19}};
std::vector<std::vector<int>> tree_to_graph_ref = {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13},
{0, 2, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25},
{0, 26, 27, 28, 29, 30}};
mln::morpho::component_tree<> trees[3]; mln::morpho::component_tree<> trees[3];
mln::image2d<int> nodemaps[3]; mln::image2d<int> nodemaps[3];
std::vector<int> depths[3]; std::vector<int> depths[3];
...@@ -70,10 +83,10 @@ TEST(Morpho, GoS) ...@@ -70,10 +83,10 @@ TEST(Morpho, GoS)
ASSERT_EQ(graph.size(), 31); ASSERT_EQ(graph.size(), 31);
for (int i = 0; i < (int)graph.size(); i++) for (int i = 0; i < (int)graph.size(); i++)
{ {
ASSERT_EQ(graph[i].size(), graph_ref[i].size()); ASSERT_EQ(graph[i].size(), graph_ref[i].size());
auto ref_it = graph_ref[i].begin(); auto ref_it = graph_ref[i].begin();
for (auto it = graph[i].begin(); it != graph[i].end(); it++) for (auto it = graph[i].begin(); it != graph[i].end(); it++)
ASSERT_EQ(*ref_it++, *it); ASSERT_EQ(*ref_it++, *it);
} }
// Compare the map tree node -> graph node // Compare the map tree node -> graph node
...@@ -87,6 +100,14 @@ TEST(Morpho, GoS) ...@@ -87,6 +100,14 @@ TEST(Morpho, GoS)
TEST(Morpho, DepthMap) TEST(Morpho, DepthMap)
{ {
// Test depth map computation for GoS // Test depth map computation for GoS
mln::image2d<int> nodemaps[3];
for (int i = 0; i < 3; i++)
std::tie(std::ignore, nodemaps[i]) = mln::morpho::tos(mln::view::channel(input, i), {0, 0});
auto depth_map = mln::morpho::details::compute_depth_map(graph_ref, tree_to_graph_ref, nodemaps);
ASSERT_IMAGES_EQ_EXP(depth_map, depth_map_ref);
} }
TEST(Morpho, Satmaxtree) TEST(Morpho, Satmaxtree)
......
Supports Markdown
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