diff --git a/glomap/math/tree.cc b/glomap/math/tree.cc index 1a0ad4e..5f329e6 100644 --- a/glomap/math/tree.cc +++ b/glomap/math/tree.cc @@ -89,6 +89,16 @@ image_t MaximumSpanningTree(const ViewGraph& view_graph, image_id_to_idx[image_id] = image_id_to_idx.size(); } + double max_weight = 0; + for (const auto& [pair_id, image_pair] : view_graph.image_pairs) { + if (image_pair.is_valid == false) continue; + if (type == INLIER_RATIO) + max_weight = std::max(max_weight, image_pair.weight); + else + max_weight = + std::max(max_weight, static_cast(image_pair.inliers.size())); + } + // establish graph weighted_graph G(image_id_to_idx.size()); weight_map weights_boost = boost::get(boost::edge_weight, G); @@ -111,11 +121,11 @@ image_t MaximumSpanningTree(const ViewGraph& view_graph, // spanning tree e = boost::add_edge(idx1, idx2, G).first; if (type == INLIER_NUM) - weights_boost[e] = -image_pair.inliers.size(); + weights_boost[e] = max_weight - image_pair.inliers.size(); else if (type == INLIER_RATIO) - weights_boost[e] = -image_pair.weight; + weights_boost[e] = max_weight - image_pair.weight; else - weights_boost[e] = -image_pair.inliers.size(); + weights_boost[e] = max_weight - image_pair.inliers.size(); } std::vector @@ -142,4 +152,4 @@ image_t MaximumSpanningTree(const ViewGraph& view_graph, return idx_to_image_id[0]; } -}; // namespace glomap \ No newline at end of file +}; // namespace glomap