# A Novel Spatiotemporal Analysis Framework for Air Pollution Episode Association in Puli, Taiwan
## 3 Proposed Methods
### Pollution Episode Segmentation  
We developed the shot boundary detection (SBD) algorithms to separate the alert category time series maps into meaningful shots (video clips). Each shot implicitly corresponds to an air pollution episode, which may contain patterns such as pollution accumulation, transportation, dispersion, and diminishing. We expect that the alert category maps contained in the same shot are more homogeneous than those falling in different shots. The activity of air pollution is very complex and related to multi-criteria such as land terrain, weather, and anthropogenic activities. There is no clear definition of how many types of air pollution patterns are observed in a place. Some ideal examples are 'clean and stable', 'pollution emerging', 'pollution transportation', 'pollution dispersion', and 'pollution dissipating'. However, there still exist other patterns that need to be explained by investigating natural and anthropogenic criteria. We propose four types of shot boundary detectors, as follows:  
1. Raster Difference (RS). The RS method reserves all of the n \(\times\) n grid values in a raster-scan order and calculates the difference of the corresponding grid values between different frames within a time window. The sum of the raster differences over the entire frame is compared to a threshold for shot detection. 2. Histogram Difference (HD). Instead of reserving the raster sequence of grid values, the HD method constructs a histogram by counting the number of grids having each level of the 10 alert categories. The 10 occurrence numbers on the histogram are used as the feature vector to calculate the difference between different frames within a time window. As compared to the RS method, the HD method is less sensitive to rotation and translation of the same pollution patterns and is more likely to extract complete shots of various episodes. 3. Edge Difference (ED). The ED method applies the Sobel edge detectors, which are commonly used in the field of image processing, to extract the boundaries between adjacent grids having significantly distinct PM\({}_{2.5}\) alert categories. The implementation of the ED method is motivated by the assumption that the edge orientation of the pollution region changes abruptly at the transition to the next episode. The four 3 \(\times\) 3 Sobel edge filters, as depicted in Figure 3, for extracting vertical, horizontal, and two  
Figure 2: 10-level air–quality alert categories modified from the six–level alert categories defined by Taiwan EPA. diagonal edges are employed to convolute the frame image. The response at each pixel to the four filters is summed up to obtain 64 edge response values as the feature vector, which is used to calculate the difference between different frames. 4. Statistics Based (SB). The SB method extracts the properties of the alert category map and detects the cutting frames, which are assumed to have large variations in these properties as compared to the frames in the next shot. In particular, we use six moment statistics; three are non-positional and the others are positional. Let the position of the n \(\times\) n grids be resolved as a two-dimensional array, and the grid value at position \([x,y]\) is denoted as \(g[x,y]\). The three non-positional moments are as follows: \[\frac{1}{n^{2}}\sum_{x=1}^{n}\sum_{y=1}^{n}(g[x,y]-\overline{g}[x,y])^{k},\;k =1,\;2,\;3\] (1) where \(\overline{g}[x,y]\) is the mean of \(g[x,y]\) over all n \(\times\) n grids. On the other hand, the positional moments designed in this paper are calculated by multiplying the grid moment element with the weighting of positional indices. \[\frac{1}{n^{2}}\sum_{x=1}^{n}\sum_{y=1}^{n}\left((g[x,y]-\overline{g}[x,y])^{k }\times(ax+b^{y})\right),\;k=1,\;2,\;3 \tag{2}\]  
where \(a\) and \(b\) are the parameters for tuning the linear and exponential weightings at position \([x,y]\). Our PM\({}_{2.5}\) episode segmentation algorithms detect episode boundaries (cuts) to separate the alert category time series into meaningful shots.