Commit 6c714d35 authored by Victor Simonin's avatar Victor Simonin
Browse files

Replace edge_t struct in alphatree and use it privately in component_tree.cpp

parent 484ee497
Pipeline #28769 passed with stage
in 22 minutes and 28 seconds
......@@ -56,6 +56,14 @@ namespace mln::morpho
details::directional_hqueue<P, N, W> m_cont;
};
template <typename P, typename W>
struct edge_t
{
P p;
P q;
W w;
};
template <typename P, typename N, typename W, bool HQ>
class alphatree_edges
{
......
......@@ -10,8 +10,6 @@
#include <mln/core/range/foreach.hpp>
#include <mln/core/trace.hpp>
#include <iostream>
#include <vector>
#include <range/v3/view/span.hpp>
......
......@@ -189,7 +189,7 @@ namespace mln::morpho
image_ch_value_t<I, int>> //
watershed_hierarchy(I input, A attribute_func, N nbh, F distance)
{
std::vector<edge_t<image_point_t<I>, std::invoke_result_t<F, image_value_t<I>, image_value_t<I>>>> mst;
std::vector<internal::edge_t<image_point_t<I>, std::invoke_result_t<F, image_value_t<I>, image_value_t<I>>>> mst;
auto [tree, nm] = internal::__alphatree<false>(input, nbh, distance, false, false, &mst);
auto attribute = attribute_func(tree, nm);
......
......@@ -3,6 +3,17 @@
namespace mln::morpho
{
namespace internal
{
template <typename P, typename W>
struct edge_t
{
P p;
P q;
W w;
};
} // namespace internal
void component_tree<void>::filter_direct(const std::vector<bool>& pred)
{
this->filter_direct_T([&pred](int x) { return pred[x]; });
......@@ -22,9 +33,9 @@ namespace mln::morpho
return depth;
}
static std::vector<mln::morpho::edge_t<int, double>> saliency_map(mln::image2d<uint8_t> node_map)
static std::vector<internal::edge_t<int, double>> saliency_map(mln::image2d<uint8_t> node_map)
{
std::vector<mln::morpho::edge_t<int, double>> res;
std::vector<internal::edge_t<int, double>> res;
auto width = node_map.width();
......@@ -38,7 +49,7 @@ namespace mln::morpho
auto offset_p = p[0] + width * p[1];
auto offset_q = q[0] + width * q[1];
mln::morpho::edge_t<int, double> edge = {offset_p, offset_q, 0};
internal::edge_t<int, double> edge = {offset_p, offset_q, 0};
edge.w = std::abs(node_map(p) - node_map(q));
......@@ -61,7 +72,7 @@ namespace mln::morpho
image2d<double> res(res_width, res_height);
fill(res, 0);
const std::vector<mln::morpho::edge_t<int, double>>& s_map = saliency_map(node_map);
const std::vector<internal::edge_t<int, double>>& s_map = saliency_map(node_map);
for (const auto [u, v, w] : s_map)
{
......
......@@ -133,7 +133,7 @@ TEST(Morpho, AlphaTreeMST)
using I = mln::image2d<std::uint8_t>;
using P = mln::image_point_t<I>;
using W = std::uint8_t;
using E = mln::morpho::edge_t<P, W>;
using E = mln::morpho::internal::edge_t<P, W>;
I ima = {
{4, 0, 0, 1}, //
......
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