35 int m_width, m_height;
36 std::unique_ptr<std::vector<Node_ptr>> m_nodes;
37 std::unordered_map<int32_t, int32_t> m_node_ids;
39 void hash_node_ids(
void);
40 void process_overlapping_edges();
43 inline Graph(std::unique_ptr<std::vector<Node_ptr>> &nodes,
int width,
int height)
44 : m_nodes(std::move(nodes)), m_width(width), m_height(height) {
50 for (
auto &node : *m_nodes) {
55 bool add_edge(int32_t node_id1, int32_t node_id2);
56 bool merge_nodes(
const Node_ptr &node_to_keep,
const Node_ptr &node_to_remove);
58 void clear_unconnected_nodes();
60 inline const std::vector<Node_ptr> &get_nodes()
const {
64 bool all_areas_bigger_than(int32_t min_area);
65 inline const size_t size() {
66 return m_nodes->size();
69 void discover_edges(
const std::vector<int32_t> ®ion_labels,
const int32_t width,
70 const int32_t height);
71 void merge_small_area_nodes(
const int32_t min_area);
72 void compute_contours();