Image preprocessing algorithm and visual implementation for face-mask wearing detection based on OpenCV
Abstract
Image preprocessing is a critical prerequisite for computer-vision tasks such as face-mask wearing detection and target classification, directly affecting the accuracy and efficiency of subsequent models. To solve image noise, uneven illumination and blurred contours commonly observed in face-mask wearing-detection scenes, this paper designs a complete preprocessing pipeline with seven core steps and implements real-time visualization based on Python and OpenCV. The pipeline includes grayscale conversion, Gaussian filtering, CLAHE contrast enhancement, adaptive threshold binarization, morphological closing, Canny edge detection and edge-morphology fusion. Experimental results on real face-mask images show that the proposed pipeline effectively removes noise, corrects illumination deviation and strengthens mask regions contours. The signal-to-noise ratio (SNR) is improved by 31.3% and the target contrast is improved by 47.9%, providing high-quality data support for subsequent face-mask wearing detection models such as YOLO.