Given the prevalent issues surrounding accuracy and efficiency in contemporary stereo-matching algorithms, this research introduces an innovative image segmentation-based approach. The proposed methodology integrates residual and Swim Transformer modules into the established 3D Unet framework, yielding the Res-Swim-UNet image segmentation model. The algorithm estimates the disparateness of segmented outputs by employing regression techniques, culminating in a comprehensive disparity map. Experimental findings underscore the superiority of the proposed algorithm across all evaluated metrics. Specifically, the proposed network demonstrates marked improvements, with IoU and mPA enhancements of 2.9% and 162%, respectively. Notably, the average matching error rate of the algorithm registers at 2.02%, underscoring its efficacy in achieving precise stereoscopic matching. Moreover, the model’s enhanced generalization capability and robustness underscore its potential for widespread applicability.