Manuscript Offprint

arXiv:2610.40029

Segment Anything Model Based Context Guided Mamba Unet for Medical Image Segmentation

Chenchen Wang, You Zhou

Abstract

Medical image segmentation is crucial for clinical diagnosis and treatment planning, requiring both global contextual understanding and fine-grained structural precision. While the Segment Anything Model (SAM) demonstrates strong generalization capabilities, its direct application to medical images often lacks domain-specific adaptability. Meanwhile, State Space Models (SSMs)-based methods, such as Mamba, efficiently capture long-range dependencies but may struggle with preserving fine anatomical details. To address these challenges, we propose a segment anything model based context guided mamba unet, SAMBA-UNet, a novel framework that integrates SAM's context knowledge with Mamba's hierarchical feature learning to enhance both global representation and local detail refinement. Specifically, we introduce the Hierarchical Context Enhancement Module (HCEM), an attention-based fusion module that deeply incorporates the multi-level features of SAM and Mamba to improve detail perception and segmentation precision. Additionally, we employ LoRA and Adapter-based fine-tuning to adapt SAM to medical imaging tasks, further enhancing its domain-specific segmentation capability and robustness. We conducted a comprehensive study on several medical segmentation datasets, including Synapse, ISIC17, and ISIC18, evaluating our method across multiple metrics. Experimental results demonstrate that SAMBA-UNet achieves state-of-the-art performance, effectively balancing generalization, segmentation accuracy, and computational efficiency. Our

*Corresponding author

Email addresses: wchenchen0808@gmail.com (Chenchen Wang), zhouy58@cardiff.ac.uk (You Zhou) code will be released upon acceptance.

Keywords: Medical image segmentation, Segment Anything Model, State Space Models.

1. Introduction

Medical image segmentation plays a crucial role in various clinical applications, including CT and MRI analysis, enabling precise extraction of pathological regions such as tumors and lesions. This aids early disease detection and accurate diagnosis [3,4]^{[3, 4]}. However, unlike natural images, medical images often exhibit complex anatomical structures and overlapping pathological tissues, making segmentation a challenging task. Traditional CNN-based models like U-Net [12]^{[12]} excel in capturing local texture and edge features, yet their limited receptive fields often fail to incorporate broader spatial relationships essential for accurate region delineation. To address this limitation, Transformer-based architectures introduced self-attention mechanisms capable of modeling global dependencies, enhancing their ability to integrate distant anatomical cues. However, their quadratic computational complexity significantly increases the burden when processing high-resolution or volumetric (3D) medical image data, often rendering them impractical for clinical deployment due to memory and inference constraints.

In response, State Space Model (SSM) architectures, particularly the Mamba family, have emerged as an efficient and context-aware alternative. Inspired by structured state-space sequence models (e.g., S4), Mamba applies these principles to visual data, enabling long-range dependency modeling with linear complexity, while also being GPU-hardware-aware. In the medical domain, hybrid CNN-SSM networks like U-Mamba combine convolutional layers for local texture and Mamba blocks for global context, demonstrating robust scalability across various imaging modalities. Pure SSM networks such as VM-UNet and SegMamba further push this model paradigm by leveraging Visual State Space modules or multi-directional Mamba blocks to process dense volumetric data efficiently and coherently. A recent survey even reports that Mamba-based architectures outperform traditional transformer and CNN approaches in high-resolution image tasks while requiring fewer resources.

The Segment Anything Model (SAM), as a foundation model trained on large-scale natural image datasets, exhibits strong generalization and zero-shot segmentation capabilities. Its prompt-driven architecture allows for flexible object delineation and cross-domain adaptability. However, when applied directly to medical imaging, SAM often fails to accurately capture low-contrast anatomical boundaries or subtle pathological regions, due to domain-specific discrepancies in semantics and texture distribution. In contrast, Mamba-style State Space Models (SSMs) have shown great promise in medical image segmentation by efficiently modeling long-range dependencies with linear computational complexity. These models are particularly effective at capturing spatial continuity and structural context across volumetric data, yet they lack the rich semantic priors that foundation models like SAM provide—limiting their performance in cases of ambiguous or poorly contrasted anatomy. These observations suggest that SAM and Mamba offer highly complementary strengths: the former provides global semantic awareness, while the latter excels at structural consistency and context reasoning. A unified framework combining the two can potentially overcome the respective limitations of each, enabling segmentation models that are both semantically informed and anatomically precise. Despite this promising direction, prior research has mostly focused on either adapting SAM to medical domains or refining Mamba-based architectures independently. To date, no studies have systematically integrated SAM's learned representations with Mamba's context modeling to address the unique challenges of medical image segmentation—a gap this work aims to fill.

To bridge this gap, we propose SAMamba-UNet, a hybrid Mamba-based model that integrates the powerful visual representation learning of SAM with the long-range contextual modeling of Mamba. Our approach employs joint fine-tuning of SAM via LoRA[25] and Adapter[26] techniques to adapt it for medical image segmentation. Extensive experiments on Synapse[44], ISIC17[42], and ISIC18[43] datasets demonstrate that SAMamba-UNet achieves competitive performance across various medical segmentation tasks, including organ and skin lesion segmentation. In summary, our primary contributions are as follows:

  1. We present SAMBA-UNet, a novel framework that integrates SAM's contextual knowledge with Mamba's hierarchical feature learning. By leveraging SAM's generalization ability and Mamba's long-range modeling, our method enhances global context understanding and fine-grained anatomical segmentation, achieving superior performance in medical image segmentation.

  2. We designed a Hierarchical Context Enhancement Module (HCEM), a novel attention-based fusion module by deep fusion of SAM and mamba features, Use SAM's powerful generalization ability to enhance the model's perception of details.

  3. We concurrently collaborative fine-tune SAM with the incorporation of both LoRA and Adapter to learn medical-specific knowledge, further enhance generalisation capabilities.

  4. We conduct extensive experiments on three datasets, and the evaluation results show that our method exhibits competitive performance.

References (43)