Traffic flow detection is an important part in Intelligent Traffic Control System. A traffic flow detection algorithm based on gray threshold is presented in this paper. When a traffic accident occurs on the neighboring lanes of the same cross section in a three lane road, the traffic flow on the other lane (inside lane or outside lane) where no traffic accident occurred is detected by using this algorithm. And the difference between the traffic flow in inside lane and in outside lane is tested by t test. The results show that the accuracy of traffic flow is more than 95% when using this algorithm, which indicates that this algorithm is feasible and effective. When a traffic accident occurs on the neighboring lanes, the difference between the traffic flow in inside lane and in outside lane is significant.