Aiming at the problem of the impact of highway rain on people's life and property safety and traffic safety, this paper proposes an algorithm based on the combination of frequency domain and spatial domain, threshold and morphology, combining high-pass filtering, full-domain value segmentation, method, mask processing, and morphological open-operated denoising to construct the rain coefficient model Prain coefficient, and judge the size of rain according to the value of Prain coefficient. And the data of sunny, cloudy, and rainy days of different sections and different periods of the Jinan Bypass G2001 line were used to verify, and then to warn about the driving safety of vehicles on the highway. The main findings of this paper are: using the rain coefficient model Prain coefficient constructed in this paper, the cloudy and rainy days can be accurately identified and the size of the rain can be judged; this method is not only applicable to highways but also to ordinary road sections; the accuracy of the model is verified and the algorithm in this paper has the highest accuracy. The research in this paper is important for road traffic safety, especially road traffic safety in bad weather such as rain.