Yijun Wang, Dongyu Zheng, Mingcai Hou, Hongjun Li, Wei Zeng, Caihua Chen, Sixuan Wu, Yujie Gao, Yifan Bai
Abstract
Accurate segmentation of particles in rock thin sections is essential for provenance reconstruction and sedimentary environment interpretation. The Segment Anything Model (SAM), a large-scale foundation segmentation model, has demonstrated strong performance and generalization across diverse domains. However, its application to petrographic image analysis remains challenging. Although paired PPL–XPL images are acquired from the same field of view, the same grain may show different optical responses under the two polarization conditions, such as reduced visibility caused by XPL extinction and weakened edge cues in PPL. This optical appearance discrepancy, rather than spatial misalignment, makes direct feature fusion unreliable and often causes the original SAM to produce coarse or over-segmented masks. To address these challenges, we propose Auto-SAM, an enhanced segmentation framework built upon SAM for dual-modal petrographic images. Auto-SAM employs a dual-modal network architecture with a feature-fusion module following the image encoder to effectively integrate complementary information from PPL and XPL images. In addition, we introduce a CAM-GLCM module, which combines Gradient-weighted Class Activation Mapping (Grad-CAM) and the Gray-Level Co-occurrence Matrix (GLCM) to highlight potential grain regions and enhance boundary localization. The resulting pseudo masks are further used to derive feature prototypes that guide SAM to focus on informative grain structures. A hybrid loss function combining Binary Cross-Entropy and Dice loss is adopted to improve training stability. Comparative experiments demonstrate that Auto-SAM significantly outperforms the original SAM and several widely used vision transformer– and CNN-based segmentation models in terms of mIoU and mPA. Furthermore, experiments with dual-modality inputs show that integrating both PPL and XPL images yields superior segmentation performance compared with single-modality approaches. These results indicate that Auto-SAM provides an effective solution for automated grain identification in rock thin sections and improves the efficiency of petrographic analysis workflows.
Citation format
WANG, Yijun, et al. An auto-prompting segment anything model for dual-modal grain segmentation in rock images. Applied Computing and Geosciences, 2026, 31: 100375.