Estimation of Traffic Occupancy using Image Segmentation

-Increased traffic flow results in high road occupancy. Traffic road occupancy is often used as a parameter for the prediction of traffic conditions by traffic engineers. Although traffic monitoring systems are based on a large number of technologies, challenges are still present. Most of the methods work efficiently for free-flow traffic but not in heavy congestion. Image processing techniques are more effective than other methods, as they are based on loop sensors and detectors to monitor road traffic. A huge number of image frames are processed in image processing hence there is a need for a more efficient and low-cost image processing technique for accurate vehicle detection. In this paper, a novel approach is adopted to calculate road occupancy. The proposed framework has robust performance under road conjunction and diverse environmental conditions. A combination of image segmentation threshold technique and shadow removal technique is used. The study comprised of segmenting 1056 images extracted from recorded videos. The obtained results by image segmentation were compared with traffic road occupancy calculated manually using Autocad. A final percentage difference of 8.17 was observed.


INTRODUCTION
Precise and accurate calculation of basic traffic flow parameters is a major step towards the successful planning and management of a traffic system. Real time traffic flow can be used to enhance the capacity of a traffic system. Traffic road occupancy is often used to determine traffic congestion and related characteristics. It is the ratio of the area occupied by vehicles to the total area of the road in a traffic scenario. Road occupancy has been a subject of interest for traffic management and planners over time [1,2]. A consequence of traffic density is road congestion and the enhanced probability of accidents. There is an exponential increase in the number of total vehicles globally during the last decade. Traffic monitoring is a difficult task due to the high traffic occupancy and issues such as shadows, occlusion etc. For the advancement of traffic monitoring systems, different methods and techniques have been applied. However, obtaining traffic road occupancy for heterogeneous traffic (e.g. the traffic of the city of Karachi) is a difficult task due to the variety of traffic modes in the traffic composition, the ranging in area and size, and little to no lane discipline. So, a method needs to be developed for obtaining road occupancy [3]. Image processing has been used in a number of ways to obtain real time traffic in terms of both model flow and density. However, the accuracy of the models generated is highly traffic dependent and occlusion reduces greatly the accuracy of the models [4]. For heterogeneous traffic, occlusion affects accuracy and real time traffic management systems cannot be adopted [3][4][5].
A spatio-temporal Markov random field algorithm for traffic images at intersections was developed in [6]. This algorithm traces each pixel of the image on the x-y plane versus the time axis. The authors also developed an extended recognition system based on hidden Markov models. This system has the ability to learn and keep track of events, thus it can be used to identify events like illegal u-turns or reckless driving. A novel framework was developed to explore multidimensional data of road traffic to examine different patterns of traffic and anomaly detection in [3]. The framework was implemented on a collection of road traffic datasets gathered from different areas of the city. A three step method was ormulated for vehicle counting in images with multiple vehicle occlusions in [7]. The first step involves the deduction of vertices for each vehicle from the camera configuration. In the second step, a contour description model is used to determine the vanishing contours with their directions to determine vehicle counts, and finally, in the last step, a resolvability index is assigned to each occluded vehicle to find out the dimensions of the occluded vehicles. Another methodology was purposed [8] [9]. In the proposed mechanism, a camera captures the image of the car and uses image segmentation algorithms to obtain the special letters. This mechanism was tested on 610 images taken under different illumination conditions. Image segmentation plays an essential role in understanding of image, investigation of medical images, video surveillance, image compression, etc. [10][11][12]. The objective of image segmentation is the clustering of pixels into image regions. These regions refer to individual objects, surfaces or parts of objects.
Most research has been done in the field of vehicle detection, vehicle tracking, vehicle recognition, and vehicle behavior understanding [4,13]. Beside these, the estimation of traffic occupancy is also essential in improving traffic management systems. In this research, image segmentation is used for the estimation of traffic occupancy. For complex traffic scenarios, image processing techniques are playing an important role in a wide range of applications. Image segmentation deals with the image processing and refers to the segregation of an image into various regions based on texture, color, or intensity. Image segmentation can be performed by different techniques and algorithms. Among these techniques we have chosen the color threshold technique to obtain road occupancy. This technique does not require prior knowledge of the image, has simple calculations, and fast operating speed. The videos were recorded during daytime, therefore the shadows of vehicles cause inaccuracy in the results. This issue is tackled by adopting a novel combination approach of color threshold with shadow removal. Threshold segmentation algorithm Otsu, which is an interclass variance method is used [14]. The results showed that this approach minimizes the error due to the shadows of vehicles and leads to a better estimation of road occupancy.

A. Otsu's Thresholding
Thresholding plays an important role in the segmentation of an image into various regions and in pattern recognition. Some grayscale values are selected automatically as threshold and the image is classified into different regions. Among various thresholding techniques, we have chosen Otsu's thresholding method [14] for this research, which is a globally accepted threshold method. Through this method, maximum separation of classes can be obtained and histogram image thresholding can be performed automatically. It is assumed that in Otsu's algorithm, an image consists of two classes, foreground ‫ܥ(‬ ) and background ‫ܥ(‬ ଵ ), and based on probability density function a normalized histogram is constructed. The probability density function is: where n is the total pixels of the image, ݊ is the pixel having intensity level ‫ݎ‬ , and ܰ is the maximum intensity level of the image. Center point between the minimum and maximum intensity level in the image is known as the initial threshold. If ݉ is the initial threshold, then the set of pixels ሺ‫ܥ‬ ሻ has levels ሾ0, 1, … … . . , m െ 1ሿ and the set of pixels ሺ‫ܥ‬ ଵ ሻ has levels ሾm, m 1, … … . . , N െ 1ሿ. The extension of Otsu's method for multilevel thresholding is given as: The optimal threshold value can be achieved by ‫ߪݔܽ݉݃ݎܽ‬ ଶ .

B. Traffic Occupancy Estimation by Otsu's Thresholding
In order to perform image segmentation, videos were recorded on the project site, which is the University road of Karachi near the Federal Urdu University. For an accurate occupancy calculation the camera needs to be parallel with the road. The more the camera is titled beyond 180 0 angle, more error will be observed. Due to site limitation and in order to attain maximum height, the camera was installed on the 5 th floor of a building. The research methodology is shown in Figure 1. Videos were recorded for different times of the day in order to have samples from all traffic conditions for analysis. The videos were cropped to obtain frames having road surface and vehicles only. After the extraction of image frames, image segmentation was performed in Matlab. The obtained results were compared with manual road occupancy results obtained in Autocad. Finally, the results were displayed by plotting graphs of image segmented occupancy and original occupancy obtained from Autocad. Proposed framework.

C. Data Collection and Analysis
Using Matlab, frames were extracted from videos at an interval of 3 frames per minute. The camera recorded the videos at 30fps (frames per second). Every minute had 1800 www.etasr.com Farooq et al.: Estimation of Traffic Occupancy using Image Segmentation frames, so the 600 th , 1200 th , and 1800 th frames of every minute were analyzed. Matlab offers multiple functions and tools to perform image segmentation. Original image and threshold image are shown in Figure 2. A binary filter was applied after thresholding to convert the image in two parts, background (black) and foreground (white). The mask created was exported to Matlab script where operations were defined including image import and applying the created mask. In order to render the small pixel areas left within the image, such as the windscreens of the cars, they were filled using the hole filling option. Finally, the total number of white and black pixels was obtained. A ratio of sum of all white pixels and a sum of all pixels gave the occupancy.  In order to calculate the accuracy of the procedure, these images were imported to Autocad and the object areas were calculated by drawing a boundary around all vehicles in the image. Figure 3 is a pictorial presentation of the calculation of the original occupancy values. A ratio of the sum of the area of all the objects to the total area of the image was computed to calculate the total occupancy.

D. Shadow Removal
In order to minimize the errors due to the formation of shadows on the road by the passing vehicles, it is necessary to devise a technique for the shadow removal. Due to the resemblance of the shadows with the dark color objects in an image often the detection and removal of shadows turns out to be a difficult task. In order to remove shadows another mask was defined in Matlab. L*a*b color space is the tool used to define the shadow removal mask. Here, L* is for the lightness and a* and b* for the green-red and blue-yellow color components. Original and shadow detected images are shown in Figure 4. III. RESULTS A total of 1056 image frames were analyzed. Based on the comparison of the average of the real occupancy calculated with Autocad vs the occupancy calculated by Matlab, a percentage difference of 33.18 was observed before the application of shadow removal mask between the actual and Matlab occupancy. After the shadow removal mask the observed difference percentage was found to be 8.17. The results are given in Table I whereas Figure 5 exhibits the difference percentage between the calculated and the observed occupancy. During the research, a large difference percentage was observed for a few frames. This can be explained by the small value of occupancy in these frames. Even a small difference between the two occupancy values can result in a considerable percentage difference.  V. CONCLUSION Based on the observed results, it can be concluded that image segmentation can be effectively used to calculate the occupancy of the road segments, while being a cost effective solution. Results can be obtained at a very quick interval compared to the convenient methods of finding occupancy. Moreover, the occlusion will have minimal effect on the calculated occupancy. It is worth mentioning that the camera angle with the road surface plays an important role on the accuracy. The closer is the angle with the road to 180 0 and the placed camera in the middle lane, the better the result will be.