diff --git a/pm2d/line_matcher.py b/pm2d/line_matcher.py index ce4f657..ce035c6 100644 --- a/pm2d/line_matcher.py +++ b/pm2d/line_matcher.py @@ -873,7 +873,20 @@ class LineShapeMatcher: ) if nms_radius is None: nms_radius = max(8, min(self.template_size) // 2) - top_thresh = min_score * self.top_score_factor + # Pruning adattivo allo step angolare: con step piccolo (<= 3 deg) + # ci sono molte varianti vicine, gli score top-level sono ravvicinati + # e top_thresh*0.5 e' troppo aggressivo: scarta varianti valide che + # sarebbero state riprese al full-res. Stessa cosa per + # coarse_angle_factor (skip 1 ogni 2): con step fine non e' utile. + # Risultato osservato: precisione "veloce" 10° dava risultati + # migliori di "preciso" 2° proprio perche evitava il pruning. + eff_step = self._effective_angle_step() + top_factor = self.top_score_factor + cf_eff = max(1, coarse_angle_factor) + if eff_step <= 3.0: + top_factor = max(top_factor, 0.7) + cf_eff = 1 + top_thresh = min_score * top_factor tw, th = self.template_size density_top = _jit_popcount(spread_top) @@ -905,7 +918,7 @@ class LineShapeMatcher: coarse_idx_list: list[int] = [] # varianti da valutare al top neighbor_map: dict[int, list[int]] = {} # vi_coarse -> indici vicini - cf = max(1, coarse_angle_factor) + cf = cf_eff for scale_key, vi_list in variants_by_scale.items(): vi_sorted = sorted(vi_list, key=lambda i: self.variants[i].angle_deg) n = len(vi_sorted)