(2) Feature Map Generation: *F*mag, *F*grad

Since the information extracted by the optical flow in the preprocessed image is expressed by the magnitude of the movement in the x and y-axes, the extracted information is converted into two feature maps: magnitude and gradient feature maps. The magnitude and the gradient of the motion vector can be calculated through the motion vector obtained using the actual optical flow. The motion vector calculated by the optical flow must be converted into a polar coordinate system to form two feature maps. The polar coordinate system is a coordinate system in which the position of a point is defined as a distance (r) and a direction (θ) from a vertex. In the Cartesian coordinate system, the relationship of the vertices, which are represented in a complicated manner by trigonometric functions, can be easily expressed in the polar coordinate system.

The two-dimensional vector (x, y) calculated as an optical flow is transformed into a value in the polar coordinate system as follows.

$$F\_{\text{mag}} = \sqrt{\mathbf{x}(t)^2 + y(t)^2},\ F\_{\text{grad}} = \arctan\left(y(t),\ \mathbf{x}(t)\right] \frac{180}{\pi} \tag{1}$$

where *F*mag is a feature map of the magnitude of the motion vector converted to the polar coordinate system, and *F*grad is a feature map of the direction of the motion vector.

Figure 3 shows the visualization image of *F*mag (Figure 3b) and *F*grad (Figure 3c) for the input video (Figure 2). Figure 3b is a visualization image of the magnitude feature of the motion of moving people, and Figure 3c is a visualization image of the numerical value of the directional feature using the HSV (Hue-Saturation-Value) color model. Since the direction ranges from 0◦ to 360◦, the size of the H channel of the HSV color model was used to express the angle in the form of a color. In Figure 3c, people walking from the front of the building to the right were represented in red, while people moving to the left were represented in blue.

**Figure 3.** Magnitude and gradient feature map. (**a**) original frame; (**b**) *F*mag; (**c**) *F*grad.
