When detecting the cracks in the tunnel lining image, due to uneven illumination, there are generally differences in brightness and contrast between the cracked pixels and the surrounding background pixels as well as differences in the widths of the cracked pixels, which bring difficulty in detecting and extracting cracks. Therefore, this paper proposes a dynamic partitioned Gaussian crack detection algorithm based on the projection curve distribution. First, according to the distribution of the image projection curve, the background pixels are dynamically partitioned. Second, a new dynamic partitioned Gaussian (DPG) model was established, and the set rules of partition boundary conditions, partition number, and partition corresponding threshold were defined. Then, the threshold and multi-scale Gaussian factors corresponding to different crack widths were substituted into the Gaussian model to detect cracks. Finally, crack morphology and the breakpoint connection algorithm were combined to complete the crack extraction. The algorithm was tested on the lining gallery captured on the site of the Tang-Ling-Shan Tunnel in Liaoning Province, China. The optimal parameters in the algorithm were estimated through the Recall, Precision, and Time curves. From two aspects of qualitative and quantitative analysis, the experimental results demonstrate that this algorithm could effectively eliminate the effect of uneven illumination on crack detection. After detection, Recall could reach more than 96%, and after extraction, Precision was increased by more than 70%.