## 3 Methodology
### Crowd Density Measures Pantic Risk
#### 3.1.2 Abnormal Change of Contour Line  
Contour is an effective method for describing the distribution of a two-dimensional density map by layers, and it can intuitively represent the change in density distribution in the form of lines. In the crowd density map, each contour line represents the boundary of the same density value, and the number, distribution shape, and area of the contour line reflect the density and changing trend of the crowd in the region. The variation in the  
Figure 1: The structure of the proposed neural network for crowd density map estimation.  
Figure 2: The Density map predicted by CDNet.  
number of contours reflects the complexity of the density distribution. For example, when there is a sudden increase in the number of contours, it often indicates a drastic change in the dense distribution of pedestrians in the area. The area surrounded by the contours reflects the size of the high-density region. When the contour area changes significantly in a short period, it may indicate a rapid gathering or dispersion of the crowd.  
For image frames continuously captured in the same scene (e.g., every second or every few frames), CDNet performs frame-by-frame inference to generate the corresponding density maps \(D_{t}(x,y)\) for multiple frames. Here, \(t\) represents a discrete time index \((t=1,2,3\ldots,T)\). Each density map \(D_{t}\) is typically a matrix with the same resolution as the input image or a downscaled version, where the values represent the estimated number of pedestrians distributed in each pixel region.  
1. Mathematical Description of Contour Features. The change in contour quantity can be defined as expressed in Equation (1). \[\Delta N_{c}=\left|N_{c}^{t+1}-N_{c}^{t}\right|\] (1) where \(N_{c}^{t}\) represent the number of contours at time \(t\), and when \(\Delta N_{c}\) exceeds a predefined threshold \(\tau_{N}\), it indicates the presence of abnormal behavior in the current frame. The total change rate of the contour area can be defined as expressed in Equation (2). \[\Delta A_{c}=\frac{\sum_{i=1}^{N}A_{i}^{t+1}-\sum_{i=1}^{N}A_{i}^{t}}{\sum_{i= 1}^{N}A_{i}^{t}+\epsilon}\] (2) where \(A_{i}^{t}\) represent the area of contour \(i\) at time \(t\), and \(\epsilon\) is a smoothing term to avoid division by zero.
2. Evaluation Rules of contour line. To effectively detect panic behavior within a region based on contour features, the following rules are proposed. These rules leverage changes in contour quantity and contour area to evaluate whether anomalies occur.
* Rules 1: (Abnormal Change in Contour Quantity). \[\Delta N_{c}>\tau_{N}\] (3) When the change in contour quantity exceeds the predefined threshold \(\tau_{N}\), it may indicate the presence of panic-induced crowding behavior at that time.
* Rules 2: (Abnormal Change in Contour Area). \[\left|\Delta A_{c}\right|\,>\tau_{A}\] (4) When the rate of change in contour area exceeds the threshold \(\tau_{A}\), it may indicate abnormal crowd gathering or dispersal behavior. Combining the above two rules, the total fraction s is calculated as shown in Equation (5) \[S=\omega_{1}\cdot\Delta N_{c}+\omega_{2}\cdot\left|\Delta A_{c}\right|\] (5) where \(\omega_{1}\) and \(\omega_{2}\) are the weights, and if the total score S exceeds a predefined threshold, it is determined that panic behavior has occurred.