BAPM: Boundary-Aware Prompt Mining for Training-Free Few-Shot Medical Image Segmentation

Qi Wen, Jiezhou He, Zhiming Luo, Shaozi LiNeurIPS 2026

TL;DR

Teaching a general-purpose vision model like the Segment Anything Model (SAM) to outline organs in medical scans using just a single example usually fails because tissues blend together, causing the model's predictions to "spill" across blurry organ borders. This paper introduces BAPM, a clever, zero-training way to build a digital fence right along an organ's edge using carefully filtered "negative" prompts. The result? State-of-the-art medical segmentation that outperforms even fine-tuned models, without updating a single neural network weight.

What Problem Does This Paper Address?

Getting radiologists to manually trace organs slice-by-slice in 3D scans is notoriously expensive. Few-shot medical image segmentation tries to bypass this: give an AI just one labeled example slice (the "support" image), and ask it to segment a new, unlabeled scan (the "query" image).

Recently, researchers started using Meta’s Segment Anything Model (SAM) to do this without any extra training—just by automatically generating point prompts ("click here!") on the query image based on visual similarity to the support image.

Here is the catch: medical images have notoriously low contrast and fuzzy borders. If you only give SAM positive prompts ("this is the liver"), its predicted mask leaks out into neighboring, visually similar tissues (over-segmentation). You might think, "Easy, just add negative prompts in the background!" Surprisingly, the authors show that random, far-away negative prompts don't just fail to stop boundary leakage—they actively confuse SAM’s mask decoder, making the final segmentation worse than using positive prompts alone.

Figure 1: (a) SAM prompt sensitivity. (b) Proposed method.

Methods

To walk the tightrope between boundary leakage and decoder confusion, the authors propose Boundary-Aware Prompt Mining (BAPM). Using a completely frozen SAM backbone (ViT-H), they extract image features from the support and query slices and run two parallel, training-free pipelines:

  1. Prototype-guided Positive Prompts (PP): Organs aren't uniform blobs; they have internal texture variations. Instead of averaging the whole organ into one representation, the authors use density-based clustering (DBSCAN) on the support organ's features and spatial coordinates. This creates multiple foreground "prototypes," which are matched via cosine similarity to the query image to drop well-distributed positive point prompts.
  2. Boundary-band Ambiguity Filtering (BAF) (The Core Innovation): To stop leaks, negative prompts need to sit right outside the organ's border—but if they sit too close on a blurry edge, you might accidentally grab an organ-like pixel and tell SAM to ignore the actual target. BAF solves this with a three-step sieve on the support mask:
  3. Band Construction: Dilate the organ mask slightly (e.g., 3 to 5 pixels) and subtract the original mask to isolate a thin "moat" around the organ.
  4. Pixel Filtering: Compare every pixel in this moat to the organ's average feature, throwing away the most similar fraction to eliminate blurry, ambiguous tissue.
  5. Cluster Filtering: Group the surviving background pixels using DBSCAN, rank the clusters, and keep only the ones least similar to the organ.

These ultra-reliable boundary prototypes are matched to the query image to place negative prompts, and both prompt sets are fed into SAM for a single, clean forward pass.

Figure 2: Overview of the proposed BAPM framework. (1) prototype-guided positive prompt (PP), (2) boundary-band ambiguity filtering (BAF), and (3) prompt-driven segmentation inference.

Datasets

Because BAPM is completely training-free, no datasets are used for training. For 1-way, 1-shot evaluation, the authors use two standard 3D abdominal benchmarks:

  • Abd-MRI (from the CHAOS challenge): 20 3D T2-SPIR MRI volumes.
  • Abd-CT: 30 volumetric CT scans.

Following standard protocols, evaluations focus on four shared organs across both datasets: the liver, right kidney, left kidney, and spleen. No new benchmarks are introduced.

Key Insights and Ideas

  • Naive negatives are actively toxic to SAM: In ablation studies on Abd-MRI, positive prompts alone scored a 69.33% Dice similarity. Adding random remote negative prompts caused performance to plummet to 51.62%. Effective negative prompts must act as local boundary fences, not arbitrary background markers.
  • Mid-level features beat deep features: When extracting features from SAM's 32-layer vision transformer to match support and query slices, the deepest layer (Layer 32) performed poorly (77.58% Dice). Layer 8 hit the sweet spot (86.05% Dice), preserving the crisp spatial and boundary details needed for precise point localization.
  • Zero-training enables effortless cross-modality: Because fine-tuned models overfit to the contrast style of their training scans (like CT), they crash when tested on another modality (like MRI). BAPM relies on SAM's general visual representations and simple similarity matching, allowing it to jump across modalities gracefully.

Key Results

BAPM achieves state-of-the-art 1-shot performance, beating both training-free methods and heavyweight models that require task-specific training:

  • Overall Accuracy: Reaches 86.37% Dice on Abd-MRI and 86.65% Dice on Abd-CT, outperforming the previous fine-tuned runner-up (FoB) by +1.91% and +0.44%, respectively, and beating training-free SAM2 by +7.76% (MRI) and +5.78% (CT).
  • Ablation Jump: Adding the boundary band and the two-stage ambiguity filtering boosts Dice scores from 69.33% (positive prompts only) all the way to 86.37%.
  • Cross-Modality Dominance: When using a CT support slice to segment an MRI query (and vice versa), BAPM scores 81.29% (CT→MRI) and 81.33% (MRI→CT), crushing the trained FoB baseline by nearly 8% and over 14%, respectively.
Figure 3: Qualitative results on six representative cases from the Abd-MRI dataset. Red stars denote positive prompts, and green stars denote negative prompts.

Limitations and Future Work

  • Tiny Targets & Support Quality: The authors note that BAPM struggles to pinpoint extremely small lesions. Because SAM downsamples images into lower-resolution feature maps, tiny structures yield sparse cues with limited discriminability. Similarly, ablations show that if the single chosen support slice only contains a tiny sliver of an organ (MinArea), Dice drops to ~70.4%.
  • Future Directions: To make prompt generation more robust when visual cues alone are scarce or tiny, the authors plan to integrate textual information—such as anatomical descriptions and clinical priors—into the pipeline.

Summary updated

Abstract

Few-shot medical image segmentation has shown great potential in reducing annotation costs for clinical applications. Recently, many few-shot methods have explored the Segment Anything Model (SAM) for training-free medical image segmentation via prompt engineering. However, existing approaches mainly focus on locating positive prompts from support images while overlooking informative background cues, making them prone to over-segmentation in anatomically similar regions. Moreover, simply introducing negative prompts cannot effectively suppress boundary leakage, and may even interfere with SAM’s mask decoding process, resulting in worse performance than using positive prompts alone. To address this limitation, we propose a training-free support-query framework, termed Boundary-Aware Prompt Mining, which introduces boundary-aware negative prompting for SAM-based few-shot medical image segmentation. Specifically, we introduce a Prototype-guided Positive Prompt strategy, which adopts a multi-center prompting mechanism to construct multiple foreground prototypes, enabling comprehensive spatial coverage in query images. Furthermore, we propose a Boundary-band Ambiguity Filtering strategy that identifies a boundary-adjacent background band and progressively removes ambiguous pixels and unreliable clusters highly similar to the foreground, enabling the selection of reliable negative prompts for suppressing false positives near foreground boundaries. The generated positive and negative prompts are jointly fed into SAM to produce refined segmentation results without additional training. Extensive experiments on Abd-MRI and Abd-CT datasets demonstrate that our method consistently outperforms existing approaches, highlighting its effectiveness and robustness under limited annotation settings. Code will be released upon acceptance.
BibTeX
@inproceedings{wen2026bapm,
  author = {Qi Wen and Jiezhou He and Zhiming Luo and Shaozi Li},
  title = {{BAPM: Boundary-Aware Prompt Mining for Training-Free Few-Shot Medical Image Segmentation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=8jdITJxUI9},
}
Figure