Introduction: Magnetic Resonance Imaging (MRI) is essential in diagnosing cervical spondylosis, providing detailed visualization of osseous and soft tissue structures in the cervical spine. However, manual measurements hinder the assessment of cervical spine sagittal balance, leading to time-consuming and error-prone processes. This study presents the Pyramid DBSCAN Simple Linear Iterative Cluster (PDB-SLIC), an automated segmentation algorithm for vertebral bodies in T2-weighted MR images, aiming to streamline sagittal balance assessment for spinal surgeons. Method: PDB-SLIC combines the SLIC superpixel segmentation algorithm with DBSCAN clustering and underwent rigorous testing using an extensive dataset of T2-weighted mid-sagittal MR images from 4,258 patients across ten hospitals in China. The efficacy of PDB-SLIC was compared against other algorithms and networks in terms of superpixel segmentation quality and vertebral body segmentation accuracy. Validation included a comparative analysis of manual and automated measurements of cervical sagittal parameters and scrutiny of PDB-SLIC's measurement stability across diverse hospital settings and MR scanning machines. Result: PDB-SLIC outperforms other algorithms in vertebral body segmentation quality, with high accuracy, recall, and Jaccard index. Minimal error deviation was observed compared to manual measurements, with correlation coefficients exceeding 95%. PDB-SLIC demonstrated commendable performance in processing cervical spine T2-weighted MR images from various hospital settings, MRI machines, and patient demographics. Discussion: The PDB-SLIC algorithm emerges as an accurate, objective, and efficient tool for evaluating cervical spine sagittal balance, providing valuable assistance to spinal surgeons in preoperative assessment, surgical strategy formulation, and prognostic inference. Additionally, it facilitates comprehensive measurement of sagittal balance parameters across diverse patient cohorts, contributing to the establishment of normative standards for cervical spine MR imaging.