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();
52 inline uint8_t
getPixel(
const std::vector<uint8_t>& img,
int w,
int h,
int x,
int y) {
53 if (x < 0 || x >= w || y < 0 || y >= h)
55 return img[y * w + x];
70 std::vector<uint8_t>
analyzeJunctions(
const std::vector<uint8_t>& skel,
int w,
int h);
73 inline Graph(std::unique_ptr<std::vector<Node_ptr>>& nodes,
int width,
int height)
74 : m_nodes(std::move(nodes))
82 for (
auto& node : *m_nodes) {
87 bool add_edge(int32_t node_id1, int32_t node_id2);
88 bool merge_nodes(
const Node_ptr& node_to_keep,
const Node_ptr& node_to_remove);
90 void clear_unconnected_nodes();
92 inline const std::vector<Node_ptr>& get_nodes()
const {
96 bool all_areas_bigger_than(int32_t min_area);
97 inline const size_t size() {
98 return m_nodes->size();
102 const std::vector<int32_t>& region_labels,
const int32_t width,
const int32_t height
104 void merge_small_area_nodes(
const int32_t min_area,
const int32_t min_thickness = 0);
105 void compute_contours();