Commit b2b976d6 authored by Bictole's avatar Bictole

Quasi Flat Zone and fix saliency tests

parent e1b40c2e
Pipeline #27415 failed with stages
in 18 minutes and 8 seconds
......@@ -72,4 +72,19 @@ namespace mln
QT qt_;
std::vector<int> root_;
};
class QCT : public HierarchyTree
{
public:
QCT(const Graph& leaf_graph);
~QCT() = default;
int get_nb_vertices() const override;
int get_parent(int node) const override;
std::vector<int> parent_;
int size_;
};
} // namespace mln
......@@ -126,4 +126,18 @@ namespace mln
int QEBT::get_nb_vertices() const { return qbt_.nb_vertices_; }
int QEBT::get_parent(int node) const { return qbt_.parent_[node]; }
QCT::QCT(const Graph& leaf_graph)
: HierarchyTree(leaf_graph)
, parent_(2 * leaf_graph.get_nb_vertices() - 1, -1)
, size_(0)
{
}
int QCT::get_nb_vertices() const { return size_; }
int QCT::get_parent(int node) const { return parent_[node]; }
} // namespace mln
......@@ -101,4 +101,38 @@ namespace mln
}
}
}
QCT quasi_flat_zone(Graph graph, QEBT qebt)
{
QBT qbt = qebt.get_qbt();
QCT qct(graph);
for (int i = 0; i < 2 * graph.get_nb_vertices() - 3; i++)
{
qct.parent_[i] = qbt.get_parent(i);
}
qct.size_ = qbt.get_nb_vertices();
for (int node = 2 * graph.get_nb_vertices() - 3; node > -1; node--)
{
auto parent = qct.parent_[node];
auto parent_of_parent = qct.parent_[parent];
if (parent == -1 || parent_of_parent == -1)
continue;
if (graph.weight_node(parent) == graph.weight_node(parent_of_parent))
qct.parent_[node] = parent_of_parent;
}
for (unsigned node = graph.get_nb_vertices(); node < qct.parent_.size() - 1; node++)
{
if (graph.weight_node(qbt.get_parent(node)) == graph.weight_node(node))
qct.parent_[node] = -1;
}
return qct;
}
} // namespace mln
\ No newline at end of file
#include <mln/hierarchies/saliency.hpp>
#include <gtest/gtest.h>
#include <fstream>
using namespace mln;
......
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