Evaluation the influence of distance-based K-means method for detecting moving vehicles

Detecting moving vehicles is one of important elements in the applications of Intelligent Transport System (ITS). Detecting moving vehicles is also part of the detection of moving objects. K-Means method has been successfully applied to unsupervised cluster pixels for the detection of moving objects. In general, K-Means is a heuristic algorithm that partitioned the data set into K clusters by minimizing the number of squared distances in each cluster. In this paper, the K-Means algorithm applies Euclidean distance, Manhattan distance, Canberra distance, Chebyshev distance and Braycurtis distance. The aim of this study is to compare and evaluate the implementation of these distances in the K-Means clustering algorithm. The comparison is done with the basis of K-Means assessed with various evaluation paramaters, namely MSE, PSNR, SSIM and PCQI. The results exhibit that the Manhattan distance delivers the best MSE, PSNR, SSIM and PCQI values compared to other distances. Whereas for data processing time exposes that the Braycurtis distance has more advantages.


Introduction
Detecting moving vehicles is one of important processes for the applications of Intelligent Transport System (ITS). Basically, detecting moving vehicles is part of the detection of moving objects. This task is an important underlying part of traffic monitoring and many other applications. The issue of computation in the detection of moving object has been studied, analyzed and the latest techniques have been proposed such as Adaptive Threshold Algorithm, Clustering Algorithms, etc.
[1]- [6]. Clustering is a technique for categorizing data into groups. Distance metrics play a very important role in the grouping process. The more similarities between data in groups, the more likely certain data items belong to a particular group. There are several algorithms available for clustering. One of them is K-Means clustering. In general, K-Means is a heuristic algorithm that partitioned the data set into K clusters by minimizing the number of squared distances in each cluster [7], [8]. The benefits of the K-Means algorithm are due to computational efficiency and ease of use. Distance metrics are assigned to find similar data objects that lead to the development of robust algorithms for data mining functionality such as classification and clustering [8]- [10]. This paper discusses the comparison results of solving two-dimensional data by applying the K-Means algorithm using different distance metrics; namely Manhattan distance, Canberra distance, Chebyshev distance and Braycurtis distance; as well as the basic K-Means algorithm applying Euclidian distance metrics. The results are displayed with the help of a histogram.

Design of the Proposed Method
First, the initial data in the form of video is converted into frames. Later a frame is extracted into images, which are then used as input for the K-Means method. K-Means is a clustering method, where the grouping process is based on different distances. After getting the cluster result in the form of a vector, it is converted into a matrix again and then the background is turned to white and the foreground is turned to black. The foreground is adjusted according to the color of the original image, while the background is left white. Next, the results are assessed using evaluation parameters such as MSE, PSNR, SSIM and PCQI. The flowchart of the proposed method is shown in Figure 1.

Moving Vehicle Detection
The vehicle detection process is divided into several stages:

Data collection
Data comes from video data of vehicles on a highway. Data is retrieved using a camera, which is stored in video format. The reason for choosing test data taken in the form of video is to examine whether the application can run in real time.

Image Sequence
Video data is converted to sequence of images. The process of transforming the video into image sequences begins with inputting the video. Next is the video reading process, where the video will be read in each frame. After that, looping of all frames in the video is performed. The next operation is to label the frames. The labelled data used for analysis is 400 data frames. Data sample of one video frame is shown in Figure 2.

Feature Extraction
The feature extraction technique converts a RGB matrix, which contains pixel into vector data. The image processing operation from the RGB matrix to vector data starts from storing RGB data. The feature extraction is done by extracting R, G and B into vectors and making 1 data for each frame.

Segmentation based Clustering
Image segmentation is considered as the basic operation that is important for meaningful analysis and interpretation of images obtained [11]- [13]. The segmentation process is applied to distinguish objects from the background and unwanted objects. This processing section is responsible for identifying moving vehicles from static objects or IOP Publishing doi:10.1088/1757-899X/1212/1/012044 3 backgrounds. Images are partitioned into groups of pixels that are homogeneous with respect to several criteria. Different groups cannot intersect and adjacent groups must be heterogeneous. The bounding box is determined based on the ratio of the area of interest when conducting a clot analysis [14]- [19]. Figure 3 shows the results before and after segmentation.

K-Means
The K-Means clustering algorithm employs Euclidean distance [17], [18] to measure the similarity between objects. Besides using the Euclidean distance, other distance metrics can also be used and this method is called the median-K method. The median-K method tries to eliminate the weakness of the K-Means method because it is less sensitive to outliers. The stages of the K-Means algorithm are as follows: -Let K be the number of clusters.
-Select K points to be taken as centroids for group K. These points can be chosen randomly. This criterion is valid unless the user has several detailed views in the data. -Calculate the distance by using the Euclidian formula/other distance formula for each data point set from each selected centroid. -Each object to the nearest cluster is based on the distance value calculated in the steps above.
-Calculate the centroid cluster again by calculating the average value of the attributes of all objects in each cluster.
-Analyze the cluster membership whether it changes or does not change. If it does not change then this is the last step, if not then go back to the step of distance calculation.

Distance
In this study, there are several distance calculations that are applied and will be analyzed at the later stages of results. The distance calculation methods used are: -Euclidean Distance Euclidean Distance is employed because it allows to determine the length of the shortest path between two points, so that it is able to measure the closeness between two features. The Euclidean Distance equation is shown in Equation 1 as follows:

Evaluation
To compare and evaluate the distance calculation methods applied in K-Means, this study assigns several measurement parameters as follows: -Mean Square Error (MSE) Mean square error (MSE) is a quality measurement that is calculated based on 2 images compared, so that the level of mismatch between the images can be seen [19], [20]. The smaller the MSE value that is generated, the more the image is compared. The MSE equation is described as follows: -Peak Signal to Noise Ratio (PSNR) Peak signal to noise ratio (PSNR) is a quality measurement calculated based on 2 image objects compared to MSE [21]- [23]. Comparison between the maximum values of the signal is measured by the amount of noise that affects the signal. The results obtained from the PSNR are said to be more similar if the PSNR value is getting bigger. PSNR is usually measured in decibels (db) written in equation (7).
Structural similarity (SSIM) is used to calculate the similarity index between 2 image objects that are compared structurally [1], [24]. The value of the SSIM demonstrates that two images have structural similarities when approaching value of 1. The SSIM formula is based on a comparison of 3 measurements of luminance, contrast and structure. The SSIM formula can be summarized as in equation (8) provided that the values α, β and γ are 1.
-Patch-based Contrast Quality Index (PCQI) Patch-based contrast quality index (PCQI) has concept such as SSIM which is used to calculate similarity indexes between two image objects [13], [25], [26]. PCQI utilizes patch-based representations that allow each new input image to be divided into three components physically meaningful. The strength of the component is determined by the new coordinate system, but the evaluation component produces a value of more than 1 if there is an increase in image. The average of the PCQI formula is written in equation (9), and the PCQI  (10) based on a comparison of three measurements of intensity, contrast and structure.

Results and Analysis
The results of vehicle detection computation are done by calculating the distances, and the number of images used for the analysis is 400 data. Based on the results obtained by applying Euclidean Distance, Canberra Distance, Chebyshev Distance, Manhattan Distance, and Braycurtis Distance in K-Means, the comparison of the MSE, PSNR, SSIM and PCQI values is shown in Table 1 below: From the results above, the smallest MSE with a value of 1.328 is generated by Manhattan distance and Manhattan distance also produces the highest PSNR value of 21.14. The higher PSNR value implies a closer resemblance between the reconstruction result and the original image. Likewise, with the SSIM, the Manhattan distance produces a value close to 1, which is 0.83. The value of SSIM means that it has structural similarity if it is close to 1. For PCQI results, the Manhattan distance also has the best value compared to the other distances, namely 0.79, which is close to 1. Comparison of the processing time of different distances can be seen in Table 2 below: Comparing the processing time, the distance of Braycurtis has the shortest time or fastest data processing, which is 0.3 second.

Conclusion
Evaluation of different distance approaches applied in the K-Means method demonstrates that the Manhattan distance produces the best values of MSE, PSNR, SSIM and PCQI compared to Euclidean distance, Canberra distance, Chebyshev distance and Braycurtis distance. Whereas for data processing time, Braycurtis distance has more advantages. It is suggested for further studies that comparisons of different distances applied in other cluster methods should be also conducted.