In order to solve the problem that the existing bolt anti-loosening line segmentation method cannot adapt to the complex environment,a fast segmentation algorithm for bolt anti-loosening line in complex environment was proposed.This algorithm can convert the Lab and RGB color spaces,and realize the nonlinear stretching of the a component and the optimal threshold segmentation of the R component in the Lab and RGB color spaces by selecting the appropriate parameter,and obtain the bolt anti-loosening line image.50 images with lighting and complex background were selected as the test set,and compared with the traditional threshold algorithm and the K-means clustering algorithm based on Lab color space,in terms of accuracy,precision,recall and running time.The experimental result shows that the proposed fast segmentation algorithm has stronger environmental adaptability and shorter time consumption in complex environment,and has high engineering application value.