# Driver Facial Expression Analysis Using LFA-CRNN-Based Feature Extraction for Health-Risk Decisions
## 3 Driver Health-Risk Analysis Using Facial Expression Recognition-Based LFA-CRNN
### Line-Segment Feature Analysis (LFA) Algorithm for Real-Time Stream Image Analysis Load Reduction  
#### 3.2.1 Pain Feature Extraction through LFA  
Even after executing facial feature extraction through the procedures specified in Section 3.1, various constraint conditions may arise when extracting a driver's facial features from real-time driving images. In analyzing a real-time streaming image, it may be hard to extract accurate facial characteristics due to the motion of the image. Accordingly, since it is necessary to reduce the dimensionality of facial feature images extracted from real-time streaming images, the LFA algorithm is proposed. The proposed LFA algorithm is a dimensionality-reduction process that reduces learning and reasoning time by reducing data dimensionality (the number of pixels) to increase the processing speed in order to handle the original large-capacity, high-resolution data. To extract information from images, the line information on a \(3\times 3\) Laplacian mask's parameter-modified filter is extracted, a one-dimensional (1D) vector is created, and the created vector is utilized as the learning model's input data. Based on such a process, this algorithm creates new data through the line-segment features. LFA uses the driver's facial contour lines calculated through the detection process to examine and classify line-segment types. To examine the line-segment types, a filter, \(f\), is used, and the elements {1, 2, 4, and 8} are acquired. Figure 4 shows the process where a driver's facial-contour line data are segmented, and the line-segment types are examined through the use of \(f\). ```
Input: [x\({}_{1}\), x\({}_{2}\),..., x\({}_{n}\)] def Division and Max-pooling of image  Y = List() forx\({}_{i}\) in [x\({}_{1}\), x\({}_{2}\),..., x\({}_{n}\)] do  sub = List() forw from0 toD\({}_{w}\)do//D\({}_{w}\),D\({}_{h}\) denote the size of the image to be divided. forh from0 toD\({}_{h}\)do //fw,fh denote the size of the filter. sub.append(x\({}_{i}\)[fw*fw: (w + 1)*fw, h*fh: (h + 1)*fh])  Y.append(sub)  Y = Max-pooling(Y, stride = (2,2), padding ='same') Output:Y[Y\({}_{1}\), Y\({}_{2}\),..., Y\({}_{n}\)]
```  
**Algorithm 1** Image Division AlgorithmFigure 4 shows the first LFA process. The contour line image calculated through pre-processing (detection) had a size of \(160\times 160\), and this image was segmented into 16 parts, as shown in Figure 4a. This process is calculated as shown in Algorithm 1. The segmented parts have a size of \(40\times 40\), and the segments are arranged in a way that does not modify the structure of the original image. These segments are max-pooled via the calculation shown in Figure 4b, and the arrangement of the segments is adjusted. This process is defined in Equation (1):  
\[ \begin{array}{c}D_{w},D_{h}=4,4,P_{w}=\frac{W}{D_{w}},P_{h}=\frac{H}{D_{h}}P[ n,m]=x[n*P_{w}:(n+1)*P_{w},m*P_{h}:(m+1)*P_{h}],\\ (0\leq n\leq 4,0\leq m\leq 4)MP[n,m]=max-pooling(P[n,m]),\end{array}  \tag{1}\]  
Equation (1) is a calculation where the contour line image obtained during pre-processing is divided into 16 equal segments, and the divided segments are max-pooled. \(D_{w}\) and \(D_{h}\) denote the number of segments in the width and height, respectively, and \(P_{w}\) and \(P_{h}\) denote the size of the segmented data from dividing the contour line image by \(D_{w}\) and by \(D_{h}\), respectively. \(P\) indicates the space for memorizing the segmented data, and the segmentation position is maintained through \(P[n,m]\), in which n and m refer to a two-dimensional array index, having a value ranging between 0 and 4. _MP_ memorizes the segmented data's max-pooling results. In every process, the sequence of the segmented images must not be lost. The sequence of the re-arranged segments must not be lost as well. Figure 4b shows the calculation where a convolution between the segment images and the filter is calculated: the parameters of the segmented images are converted, the sum of the parameters is calculated, and one-dimensional vector data are generated.