# Time Classification Algorithm Based on Windowed-Color Histogram Matching
## 3 Proposed Time Classification Algorithm
### Time Classification
#### 3.2.2 Histogram Comparison Methods  
Correlation is a statistical technique that shows the relationship between two variables, whether it is linear or non-linear and how strongly they are related. The result of a correlation is called the correlation coefficient and the equation of it is:  
\[d(H_{1},H_{2})=\frac{\sum_{I}(H_{1}(I)-\overline{H}_{1})(H_{2}(I)-\overline{H}_{ 2})}{\sqrt{\sum_{I}\left(H_{1}(I)-\overline{H}_{1}\right)^{2}\sum_{I}\left(H_{2 }(I)-\overline{H}_{2}\right)^{2}}}, \tag{2}\]  
where \(I\) is an index of histogram bins and \(H_{1}(I)\) and \(H_{2}(I)\) are the histograms. In addition \(\overline{H}_{k}\) is the average value of intensity. The denominator of this equation stands for the multiple of the standard deviation of \(H_{1}(I)\) and \(H_{2}(I)\). The numerator stands for the covariance of \(H_{1}(I)\) and \(H_{2}(I)\), so it means the change between \(H_{1}(I)\) and \(H_{2}(I)\). The possible value of the correlation lies between \(-1\) and \(1\). If two histograms are closely related, \(d(H_{1},H_{2})\) is closer to \(+1\) or \(-1\). If not related, then \(d(H_{1},H_{2})\) is closer to \(0\).  
Figure 3: Reference color histograms (B, G, R bands) of each time period. (**a**) Reference color histogram of “dawn” or “dusk” time periods. (**b**) Reference color histogram of “day” time period. (**c**) Reference color histogram of “night” time period.  
* Intersection Intersection Intersection calculates the similarity of two probability distributions or histograms [38]. The equation is: \[d(H_{1},H_{2})=\sum_{I}min(H_{1}(I),H_{2}(I)),\] (3) where \(I\) is an index of histogram bins and \(H_{1}(I)\) and \(H_{2}(I)\) are the histograms. The possible value of the intersection lies between 0 and 1. If two histograms are closely related, \(d(H_{1},H_{2})\) becomes a larger number. If not related, then \(d(H_{1},H_{2})\) is closer to 0, which means there is no overlap.
* Bhattacharyya  
Bhattacharyya distance measures the similarity of two probability distributions or histograms [39]. The Bhattacharyya coefficient is a measure of the amount how two probability distributions or histograms are overlapped. The equation of Bhattacharyya coefficient is:  
\[BC(H_{1},H_{2})=\sum_{I}\sqrt{H_{1}(I)\cdot H_{2}(I)}, \tag{4}\]  
Figure 4: The windowed-based color histograms of the generated reference color histograms. (**a**) “dawn” or “dust” case. (**b**) “day” case. (**c**) “night” case.  
where \(I\) is an index of histogram bins and \(H_{1}(I)\) and \(H_{2}(I)\) are the histograms. As you can see, the Bhattacharyya coefficient stands for the sum of discrete probability distribution, which is overlapped between two probability distributions or histograms and the range is [0,1]. If two histograms are closely related, \(d(H_{1},H_{2})\) is closer to 1. \(d(H_{1},H_{2})\) will be 0, if there is no overlap at all. In fact, Hellinger distance can be defined as:  
\[d(H_{1},H_{2})=\sqrt{1-BC(H_{1},H_{2})}. \tag{5}\]  
According to the Bhattacharyya coefficient, if two histograms are closely related, \(d(H_{1},H_{2})\) is closer to 0. If not related, then \(d(H_{1},H_{2})\) is closer to 1.  
* Chi-Square  
Chi-square distance is one of the distance measures that can be used to find dissimilarity between two histograms [40]. The expression can be defined as:  
\[d(H_{1},H_{2})=\sum_{I}\frac{\left(H_{1}(I)-H_{2}(I)\right)^{2}}{H_{1}(I)}, \tag{6}\]  
where \(I\) is an index of histogram bins and \(H_{1}(I)\) and \(H_{2}(I)\) are the histograms. It means the difference against the denominator histograms. If two histograms are closely related, \(d(H_{1},H_{2})\) becomes 0, because \(H_{1}(I)-H_{2}(I)\) becomes 0. If not related, then \(d(H_{1},H_{2})\) becomes a larger number.  
To summarize, Intersection and Bhattacharyya methods are techniques used to measure the similarity of two histograms by calculating the overlap area. Therefore, these methods are effective for comparing histograms that have different color features.