# L25 · Grid-generated candidates for the two contour pairs

## Development diagnostic · 2026-12-01

**Question.** Can the L19 regular grid generate useful mask candidates where R25's detector misses both reference boxes? Apply the earlier, unchanged grid procedure to the same two selected [Khanom](https://doi.org/10.5281/zenodo.21295927) images examined in L24/R25. These are adjacent diatom candidates with intersecting source contours; expert confirmation of true physical overlap and contour semantics is still missing. Selection used the annotations, images were inspected before this test, and model training-data overlap, annotation completeness and sample independence are unknown.

Resize each image to 768 × 576, lay 108 positive points on a fixed grid (64-pixel spacing and 32-pixel offset), and run MobileSAM with a cached image embedding. Keep masks with model quality score at least 0.6 and area 300–50,000 pixels; suppress lower-scored masks at mask IoU ≥ 0.8 with a retained mask. These are L19's heuristic thresholds, not values calibrated on this test set. Sort surviving masks by the model's own predicted quality, then consider the first 5, 10, 20, or all masks. Posthoc assign up to one distinct mask to each of the two annotated targets at mask IoU ≥ 0.5, maximizing the number of matched targets then total IoU. The reference is used for **scoring and matching**, not inference. It is not an automatic procedure to identify which mask is correct.

| Image | Full-field masks after suppression | Top 5 | Top 10 | Top 20 | All |
|---|---:|---:|---:|---:|---:|
| `Pin_SL_011.jpg` | 37 | 0 / 2 | 2 / 2 | 2 / 2 | 2 / 2 |
| `image003.jpg` | 26 | 0 / 2 | 0 / 2 | 2 / 2 | 2 / 2 |

For the first image, the first budget containing distinct matches has confidence-ranked masks at indices 7 and 9 (zero-based) with mask IoUs 0.945 and 0.681. For the second, indices 10 and 12 have IoUs 0.838 and 0.846. Reference-selected IoU ≥ 0.5 matches do not mean the displayed candidate is an acceptable biological outline; the first example's 0.681 target is a reminder that the threshold is permissive. Other candidates may be real but unlabeled diatoms, debris, duplicates or artifacts; these data cannot establish a false-positive rate. A larger budget can improve measured availability but requires inspecting more candidates, and actual review time is unmeasured.

R25's frozen detector produced three and ten boxes, matching 0/2 and 2/2 references using **box IoU**, whereas this experiment uses **mask IoU**. They are not a matched-quality, matched-cost head-to-head comparison. **R26 follow-up:** prompting every detector box and scoring the resulting masks found 2/2 matches on both images, including the image where no detector boxes met the box-IoU criterion. Thus the apparent grid advantage from comparing the R25 box count with these mask counts was misleading. [See the matched-mask comparison](/results/r26/). The grid has a potential discovery role, but the fixed model-quality order does not uniquely identify the desired candidates. Suppression can also remove distinct overlapping instances. Scores and [candidate-budget chart](/results/l25/) are provided without source image pixels; rights on the source record remain unspecified.

**Next.** Evaluate ranking and distinct-group preservation on an untouched, expert-adjudicated Academy benchmark, including candidates per field and measured review time. Compare detector-guided and grid candidates with the same mask matching rule and equal candidate budgets; test cross-plane support to rank candidates and handle legitimate overlap. Keep a separate set for selecting thresholds. Reproduce with `YOLO_CONFIG_DIR=/tmp/diatom-yolo-config MPLCONFIGDIR=/tmp/mpl-diatom /tmp/diatom-research-venv/bin/python research/l25_grid_overlap_candidates.py` after L24's temporary data and `/tmp/mobile_sam.pt` are available. The run stores derived scores and candidate summaries, not source image pixels or masks.
