diff --git a/src/atm/vision.py b/src/atm/vision.py index 2a1016c..6821062 100644 --- a/src/atm/vision.py +++ b/src/atm/vision.py @@ -103,9 +103,11 @@ def find_rightmost_dot( diff = np.linalg.norm(roi_img.astype(np.float32) - bgr_bg, axis=2) mask = (diff > bg_tol).astype(np.uint8) - # Connected components → one component per dot. Anti-aliasing bridges - # between adjacent dots are small enough that 8-connectivity still - # separates them cleanly. + # Anti-aliasing bridges between adjacent dots can fuse the entire strip + # into one blob under 8-connectivity. Erode by 2px to sever those bridges + # before labelling — dots shrink but remain well above min_cluster_px. + kernel = np.ones((3, 3), dtype=np.uint8) + mask = cv2.erode(mask, kernel, iterations=2) n_labels, _labels, stats, centroids = cv2.connectedComponentsWithStats( mask, connectivity=8, )