Image preprocessing algorithm and visual implementation for traffic signal lights based on OpenCV
Abstract
Image preprocessing is a critical prerequisite for computer-vision tasks such as traffic-signal-light recognition and target classification, directly affecting the accuracy and efficiency of subsequent deep learning models. To address common defects including image noise, uneven illumination and blurred object contours in practical traffic-signal-light recognition scenarios, this paper designs a complete seven-step image preprocessing pipeline and realizes real-time visual display based on Python and OpenCV. The proposed pipeline sequentially implements grayscale conversion, Gaussian filtering, CLAHE contrast enhancement, adaptive threshold binarization, morphological closing operation, Canny edge detection and edge-morphology result fusion. Experimental validation on real-world traffic signal light images demonstrates that this pipeline can effectively eliminate noise interference, compensate for uneven illumination and strengthen the contour features of traffic signal lights. Quantitative results show that the signal-to-noise ratio (SNR) is improved by 32.1% and the target contrast is increased by 51.8%. The optimized image data can provide reliable support for downstream traffic-signal-light recognition models represented by YOLO series.