# Random Forest Feature Selection and Back Propagation Neural Network to Detect Fire Using Video

Authors: Jin-Xing Liang; Jian-Fu Zhao; Ning Sun; Bao-Jun Shi
Journal: Journal of Sensors
 (2022)

---

## Abstract

As the most common serious disaster, fire may cause a lot of damages. Early detection and treatment of fires are of great significance to ensure public safety and to reduce losses caused by fires. However, traditional fire detectors are facing some focus issues such as low sensitivity and limited detection scenes. To overcome these problems, a video fire detection hybrid method based on random forest (RF) feature selection and back propagation (BP) neural network is proposed. The improved flame color model in RGB and HSI space and the visual background extractor (ViBe) in moving target detection algorithm are used to segment the suspected flame regions. Then, multidimensional features of flames are extracted from the suspected regions, and these extracted features are combined and selected according to the RF feature importance analysis. Finally, a BP neural network model is constructed for multifeature fusion and fire recognition. The test results on several experimental video sets show that the proposed method can effectively avoid feature interference and has an excellent recognition effect on fires in a variety of scenarios. The proposed method is applicable for fire recognition applied in video surveillance and detection robots.


---

## Body

## 1. Introduction

With the continuous improvement of social development, the possibility of fires with large losses is also increasing. The traditional fire recognition methods mainly use detectors to sample the temperature, spectrum, and smoke of a specific region to determine whether a fire has occurred [1]. However, due to the limitation of the detection range and sensitivity of the detector, it is difficult to achieve timely detection in open spaces and harsh environments.In recent years, fire recognition based on image processing technology has become the focus of researchers’ attention. By analyzing the static and dynamic features of flame, researchers can distinguish flames from other objects. The static features of flame mainly include color and texture features. Chen et al. [2] proposed a flame recognition rule in RGB and HSI color space by analyzing the chromaticity and disorder of flames. Celik and Demirel [3] proposed a flame classification model based on YCbCr color space, and this flame model can better adapt to lighting changes compared with the RGB color model. Wang and Ren [4] improved the image brightness by performing histogram equalization on the V channel in HSV color space and then combined the flame pixel distribution rules in RGB and YCbCr color space to perform image segmentation. Prema et al. [5] extracted texture features based on wavelet decomposition and then used an extreme learning classifier to classify images. Their method can effectively eliminate red interference. Sheng et al. [6] studied the color, texture, and gray-scale statistical features of flame images and constructed a deep belief network (DBN) for fire detection. Jamali et al. [7] introduced texture features based on color features to detect fires. They combined different features to improve the accuracy of the fire detection system.The dynamic features of flame mainly include motion features and geometric change features. Barnich and Van Droogenbroeck [8] proposed a visual background extractor (ViBe) algorithm, which provides a new idea for extracting flame motion features. To improve the overall performance of a fire detection system, Foggia et al. [9] attempted to combine the information of color, motion, and shape change to reduce the false alarm rate of the system. Gong et al. [10] proposed a flame centroid stabilization algorithm. They used color and motion features to segment suspected flame regions and further judged whether it is a flame by analyzing the changes of its area, shape, and center of mass.The fire recognition model mainly includes machine learning classifiers and deep learning networks. Yang et al. [11] analyzed the shape features of flames and used support vector machine (SVM) to recognize fire images. Huang and Du [12] proposed a fire recognition method combining rough set (RS) theory and SVM. Their method can reduce overfitting and improve the accuracy of fire prediction. Qu et al. [13] extracted the red and blue color components and brightness component of flames in YCbCr color space and used the back propagation (BP) neural network model to detect fires. Li and Zhao [14] performed fire detection based on convolutional neural network (CNN) such as Faster-RCNN, R-FCN, SSD, and YOLO v3. Sheng et al. [15] improved the detection capabilities of flames and smokes by combining simple linear iterative clustering (SLIC), density-based spatial clustering of application with noise (DBSCAN), and CNN. Muhammad et al. [16] proposed a CNN framework for fire detection. The framework can be applied to video surveillance systems.The above researches have enriched and developed fire recognition methods, but there are still some important problems. Firstly, region segmentation based on color features will inevitably overlap with the color space of other objects, which may result in inaccurate segmentation of suspected flame regions. Secondly, the extracted flame features are not comprehensive or have little correlation to the classification and recognition model, which makes it difficult to achieve accurate fire recognition in complex scenes. Thirdly, deep learning methods require high equipment performance, and the related model training and testing are complex.In view of the shortcomings of the current fire recognition methods, the flame color model and the ViBe algorithm are combined to segment suspected flame regions in this paper. Then, multidimensional features are extracted on the suspected flame regions, and the random forest (RF) method is used to analyze the importance of each feature, and then, these features are combined and selected accordingly. Finally, a BP neural network model is built for fire detection. The proposed fire detection method is verified by using several experimental video sets.This paper is organized as follows: Section2 describes a hybrid approach adopted in this study. Section 3 presents experiments and experimental results with discussions. Section 4 concludes this paper.


## 2. Hybrid Method

### 2.1. Region Segmentation Based on Color Model and ViBe Algorithm

Region segmentation is a process to divide an image (being processed) into multiple regions with different characteristics and then to separate the target region from its background. The flame presents a special color distribution pattern and has the dynamic characteristics of spreading and diffusion. Therefore, the suspected flame region in an image can be segmented by using the color model and moving target detection method.


#### 2.1.1. Color Model for Segmentation

In order to describe the color distribution of flame pixels, a statistical flame color model can be established. Yan et al. [17] established a color model of flames in RGB and HSI color space. The color model overcomes the cavity inside flames to a great extent, but there is still undersegmentation of the interference with high saturation. In the study of flame image saturation, Horng et al. [18] proposed an HSI color model of flames, which restricted the saturation component. Combining the characteristics of flames in RGB and HSI color space, we adopt the flame color segmentation rules as shown in
(1)R≥B,G≥B,R≥R0,S≥S0,R≥R1,G≥G1orT1≥Th1,T2≥Th2,T2+T3≥Th3,where T1=∣R−G∣, T2=∣G−B∣, and T3=∣R−B∣. R, B, and G are the red, blue, and green color components of an image, respectively. R0 is the threshold of the red component of an image. S0 is the threshold of the saturation of an image. For a darker environment, S0=20, and a brighter environment, S0=40. R1 and G1 are the improved thresholds of the red and green components of an image, respectively. Th1, Th2, and Th3 are the thresholds of T1, T2, and T2+T3, respectively.We use the improved color model, equation (1), to separate the region in the image that meets the constraints of the color model from the background. The images collected by Chino et al. [19] were used to test the segmentation effect. Figure 1 shows a segmentation example of a flame image using different flame color models.Figure 1
Segmentation example using different flame color models: (a) original flame image; (b) segmented image with the color model in [17]; (c) segmented image with the improved color model; (d) binarized image.
(a)(b)(c)(d)From Figure1, it can be found that compared with the method in [17], the improved color model can effectively eliminate the brown-yellow wood and the illuminated ground and achieve the accurate segmentation of the flame regions.


#### 2.1.2. ViBe Moving Target Segmentation

It is difficult to exclude objects whose colors are highly similar to flames only by using the color model, so it is necessary to segment moving objects based on the dynamic features of flames in a video. In the process of fire recognition, the interframe difference method [20], optical flow method [21], or background subtraction method [22] are commonly used to segment moving targets. The interframe difference method has low computational complexity, but it depends too much on the moving speed of the target. The optical flow method is computationally complex and sensitive to light. The background subtraction method is simple, and the extracted target is complete. The background subtraction method includes Gaussian mixture modeling (GMM) [23] and ViBe modeling methods [24] to establish the background statistical model. Compared with the GMM method, the ViBe algorithm randomly selects neighborhood pixel values to model or update the background according to the similarity between the neighboring pixels and does not need a lot of estimation or operation, so its time complexity to build a background model is lower. The followings are the calculation process of the ViBe algorithm:
(1)
Background model initialization. The background model initialization is the process to fill pixel sample set for building a background model. For each pixel in an image, usevix,y to represent its pixel value. Taking a certain point x,y as the center, N samples are randomly selected within a certain radius to build a sample set of the background model. The sample set vx,y can be defined as follows:(2)vx,y=v1x,y,v2x,y,⋯,vNx,y(2)
Moving target detection. For the pointx,y in an image to be tested, its pixel value mx,y is compared with each sample value in the background model. If the absolute value of the difference with a certain sample point is greater than a given threshold K0, the sample point is considered not similar to the point to be detected. If there are more than the given number K1 of sample points that are not similar to the point to be detected, the point is considered to be the foreground (moving target). Otherwise, the detected point is the background, as shown in(3)Dnx,y=1,mx,y−vnx,y>K0,0,others,(4)fx,y=1,∑n=1NDnx,y>K1,0,others,where Dnx,y represents the distance between the point to be detected and the nth sample point. fx,y represents the judgment result of background or foreground
(3)
Background model update. The ViBe algorithm uses a random updating strategy to update the background model from time to time. After a certain period of timet, the probability Pt,t+dt that a certain sample in the sample set is still retained can be defined as follows:(5)Pt,t+dt=N−1Nt+dt−tThe accuracy of region segmentation will affect feature extraction. The more accurate region segmentation is, the more extracted flame features can reflect the actual situation of flames. In the proposed hybrid method of video fire detection, color and motion features are combined for region segmentation. Based on the color distribution of flames in RGB and HSI color space, the improved color model is adopted to obtain segmented images. Meanwhile, the ViBe algorithm is adopted to obtain segmented images based on motion feature. The improved color model segmentation images and ViBe algorithm segmentation images are intersected, and the final suspected flame regions are obtained after corrosion, expansion, and region filling. Figure2 shows some segmentation examples based on the improved color model and ViBe algorithm. As shown in Figure 2, the region segmentation method combining the improved color model and ViBe algorithm can effectively exclude the land with color similar to flame and the moving pedestrians and get an accurate flame region.Figure 2
Segmentation examples based on the flame color model and ViBe algorithm: (a) original flame images; (b) segmented images with the improved color model; (c) segmented images with the ViBe algorithm; (d) segmented images with the improved color model and ViBe algorithm.
(a)(b)(c)(d)


### 2.2. Multidimensional Feature Extraction and RF Feature Selection

With the improvement of the ability of sensors to obtain information, multifeature fusion technology is widely used in the field of image recognition [25]. After region segmentation, there may still be regions that are mistakenly segmented as flames. Thus, it is necessary to extract multidimensional features such as geometry, texture, and dynamics of images and use multifeature fusion technology to achieve fire detection. However, some features are irrelevant or redundant to the recognition model, so it is necessary to select the feature subset with high discriminative ability from the multidimensional features.


#### 2.2.1. Multidimensional Feature Extraction

The multidimensional features extracted from an image mainly include its circularity, aspect ratio, texture features, area change rate, flicker feature, and edge jitter feature. The followings are a brief introduction and related formulas for each of them:(1)
Circularity. Circularity reflects the degree to which the shape of the target region is close to a theoretical circle. The circularityC is calculated as(6)C=4πSL2,where S represents the area of the flame region and L represents the perimeter of the flame region
(2)
Aspect ratio. Aspect ratio reflects the stretching degree of a flame. The aspect ratioW is calculated as(7)W=EH,where E represents the width of the smallest rectangle in the flame region and H represents the length of the smallest rectangle in the flame region
(3)
Texture features. In the description of the spatial relationship of image textures, the commonly used method is based on the statistical gray-level cooccurrence matrix (GLCM) [26], which is used to calculate the representative contrast, correlation, energy, and homogeneity of texture features. Specifically, the pixel offset is set to 1, and the texture feature statistics are calculated from the GLCM at four different angles of 0°, 45°, 90°, and 135°, and then, the average value of the four directions is taken as texture feature criterion for fire recognition.The gray value of two points at a certain distance in an image is represented byi,j. Suppose Pi,j is the probability of the gray value i,j. The formula of its contrast f1, correlation f2, energy f3, and homogeneity f4 of the image is as follows:
(8)f1=∑i=1K∑j=1Ki−j2Pi,j,f2=1σxσy∑i=1K∑j=1KijPi,j−μxμy,f3=∑i=1K∑j=1KP2i,j,f4=∑i=1K∑j=1KPi,j1+i−j2,where K represents the gray level of an image. μx and μy represent the mean value of Pi,j in row and column, respectively. σx and σy represent the standard deviation of Pi,j in row and column, respectively
(4)
Area change rate. Area change rate represents the area change of a flame region. The area change rate∆S is calculated as(9)△S=Sn−Sn−1Sn−1,n≥2,where Sn represents the area of the flame region in the current frame and Sn−1 represents the area of the flame region in the previous frame
(5)
Flicker feature. Flame flicker will cause the image pixels to change from nonflame to flame. In order to effectively reflect the flicker characteristics of a flame without increasing the complexity of the algorithm, the change amplitude of the flame foreground is used to characterize the flicker feature of the flame. The flicker feature∆F is calculated as(10)△F=Sn∩S̄n−1∪Sn−1∩S̄nSn,n≥2(6)
Edge jitter feature. Edge jitter measures the degree of the edge change of an object in the process of deformation. The edge jitter feature∆L is calculated as(11)△L=Ln−Ln−1Ln−1,n≥2,where Ln represents the perimeter of the flame region of the current frame and Ln−1 represents the perimeter of the flame region of the previous frame


#### 2.2.2. Random Forest Feature Selection

Random forest (RF) [27] is an integrated machine learning method that uses decision tree as the basic learner and makes decision through voting mechanism. For feature selection, the importance of a single feature variable is calculated by the RF method, and then finding the feature variables that are highly related to the dependent variable. Thus, we can select a small number of feature variables which can fully guarantee the accuracy of the prediction results.The purpose of feature selection is to select the relevant feature subset from the existing feature set. After feature extraction on the suspected flame region, we can get a 9-dimensional feature vectorCWf1f2f3f4∆S∆F∆L. We use the RF method to select the features with a strong correlation with the actual results as the input of the BP neural network model.Since there is no published standard dataset in the field of fire prevention and detection at present, we mainly use a series of typical databases proposed in [28–30] to build our video set. Our video set includes 30 fire videos and 10 interference videos. Fire videos mainly include different shapes of flames in indoor, highway, and forest scenes. Interference videos mainly include street lights, car lights, and red objects. The resolution of the videos is uniformly adjusted to 1280×720, and 20 consecutive frames of images are selected from each video to form a sample dataset. The sample dataset has a total of 800 images, some of which are shown in Figure 3.Figure 3
Some images of the sample dataset.In this paper, the suspected flame regions are segmented on the sample dataset and the multidimensional features of the flame are extracted. The RF feature importance is calculated based on the Scikit-learn tool in the Python machine learning library. Specifically, the number of decision trees in the RF is set to 100, and the maximum depth of the decision trees is set to unlimited. The minimum number of samples required to split an internal node is set to 2; the minimum number of samples required to be at a leaf node is set to 1. The measurement criterion of split quality is set to mean square error (MSE). The ranking of the feature importance is given in Figure4. From Figure 4, it can be found that flicker feature has the highest ranking and edge jitter feature has the lowest ranking.Figure 4
Feature importance ranking.According to the ranking in Figure4, the flame features are divided into combined features F1-F9, which, respectively, represent ∆F, f1∆F, Cf1∆F, CWf1∆F, CWf1f3∆F, CWf1f3f4∆F, CWf1f2f3f4∆F, CWf1f2f3f4∆S∆F, and CWf1f2f3f4∆S∆F∆L. The BP neural network method is used for training and classification, and the correct classification results of each combination feature are given in Figure 5. The correct classification rate is the average of 10 prediction results.Figure 5
Combination feature classification results.According to the classification results of the combined features as shown in Figure5, the correct classification rate of samples reaches a high level starting from the 5th combined feature, F5, and with the increase of features, the correct classification rate of samples tends to be stable. To avoid interference caused by excessive features and ensure the accuracy of classification results, the 5th combined feature, F5, is selected for fire recognition, which includes circularity, aspect ratio, contrast, energy, and flicker feature.


### 2.3. Construction of the BP Neural Network Model

The BP neural network [31] is also called error back propagation neural network. Because the weights of neurons in adjacent layers are interrelated, the network has a nonlinear mapping ability to solve complex problems. Considering the simplicity and practicability, a three-layer BP neural network with one input layer, one hidden layer, and one output layer is constructed for multifeature fusion and fire recognition.The number of nodes in the input layer of the BP neural network depends on the dimension of the feature vector. In this paper, five features of each fire image are selected to form the feature vectorCWf1f3∆F, so there are 5 nodes in the input layer. The output layer outputs the recognition result, so there is 1 node. The normalized output value ranges from [0, 1], and when the output value belongs to [0, 0.5), it means nonflame. When the output value belongs to [0.5, 1], it is expressed as flame. The number of hidden layer nodes is calculated using empirical equation (12), in which, m and n represent the number of nodes in the input layer and output layer, respectively, and a is a constant between [1, 10]. Through repeated experiments, it is found that when the number of the hidden layer nodes h is 10, the neural network achieves the optimal training effect.
(12)h=m+n+a.Based on above analysis, the structure of the BP neural network constructed in this paper is given in Figure6. The BP neural network model will be used for fire recognition in the following section.Figure 6
Structure diagram of the constructed BP neural network.


## 2.1. Region Segmentation Based on Color Model and ViBe Algorithm

Region segmentation is a process to divide an image (being processed) into multiple regions with different characteristics and then to separate the target region from its background. The flame presents a special color distribution pattern and has the dynamic characteristics of spreading and diffusion. Therefore, the suspected flame region in an image can be segmented by using the color model and moving target detection method.


### 2.1.1. Color Model for Segmentation

In order to describe the color distribution of flame pixels, a statistical flame color model can be established. Yan et al. [17] established a color model of flames in RGB and HSI color space. The color model overcomes the cavity inside flames to a great extent, but there is still undersegmentation of the interference with high saturation. In the study of flame image saturation, Horng et al. [18] proposed an HSI color model of flames, which restricted the saturation component. Combining the characteristics of flames in RGB and HSI color space, we adopt the flame color segmentation rules as shown in
(1)R≥B,G≥B,R≥R0,S≥S0,R≥R1,G≥G1orT1≥Th1,T2≥Th2,T2+T3≥Th3,where T1=∣R−G∣, T2=∣G−B∣, and T3=∣R−B∣. R, B, and G are the red, blue, and green color components of an image, respectively. R0 is the threshold of the red component of an image. S0 is the threshold of the saturation of an image. For a darker environment, S0=20, and a brighter environment, S0=40. R1 and G1 are the improved thresholds of the red and green components of an image, respectively. Th1, Th2, and Th3 are the thresholds of T1, T2, and T2+T3, respectively.We use the improved color model, equation (1), to separate the region in the image that meets the constraints of the color model from the background. The images collected by Chino et al. [19] were used to test the segmentation effect. Figure 1 shows a segmentation example of a flame image using different flame color models.Figure 1
Segmentation example using different flame color models: (a) original flame image; (b) segmented image with the color model in [17]; (c) segmented image with the improved color model; (d) binarized image.
(a)(b)(c)(d)From Figure1, it can be found that compared with the method in [17], the improved color model can effectively eliminate the brown-yellow wood and the illuminated ground and achieve the accurate segmentation of the flame regions.


### 2.1.2. ViBe Moving Target Segmentation

It is difficult to exclude objects whose colors are highly similar to flames only by using the color model, so it is necessary to segment moving objects based on the dynamic features of flames in a video. In the process of fire recognition, the interframe difference method [20], optical flow method [21], or background subtraction method [22] are commonly used to segment moving targets. The interframe difference method has low computational complexity, but it depends too much on the moving speed of the target. The optical flow method is computationally complex and sensitive to light. The background subtraction method is simple, and the extracted target is complete. The background subtraction method includes Gaussian mixture modeling (GMM) [23] and ViBe modeling methods [24] to establish the background statistical model. Compared with the GMM method, the ViBe algorithm randomly selects neighborhood pixel values to model or update the background according to the similarity between the neighboring pixels and does not need a lot of estimation or operation, so its time complexity to build a background model is lower. The followings are the calculation process of the ViBe algorithm:
(1)
Background model initialization. The background model initialization is the process to fill pixel sample set for building a background model. For each pixel in an image, usevix,y to represent its pixel value. Taking a certain point x,y as the center, N samples are randomly selected within a certain radius to build a sample set of the background model. The sample set vx,y can be defined as follows:(2)vx,y=v1x,y,v2x,y,⋯,vNx,y(2)
Moving target detection. For the pointx,y in an image to be tested, its pixel value mx,y is compared with each sample value in the background model. If the absolute value of the difference with a certain sample point is greater than a given threshold K0, the sample point is considered not similar to the point to be detected. If there are more than the given number K1 of sample points that are not similar to the point to be detected, the point is considered to be the foreground (moving target). Otherwise, the detected point is the background, as shown in(3)Dnx,y=1,mx,y−vnx,y>K0,0,others,(4)fx,y=1,∑n=1NDnx,y>K1,0,others,where Dnx,y represents the distance between the point to be detected and the nth sample point. fx,y represents the judgment result of background or foreground
(3)
Background model update. The ViBe algorithm uses a random updating strategy to update the background model from time to time. After a certain period of timet, the probability Pt,t+dt that a certain sample in the sample set is still retained can be defined as follows:(5)Pt,t+dt=N−1Nt+dt−tThe accuracy of region segmentation will affect feature extraction. The more accurate region segmentation is, the more extracted flame features can reflect the actual situation of flames. In the proposed hybrid method of video fire detection, color and motion features are combined for region segmentation. Based on the color distribution of flames in RGB and HSI color space, the improved color model is adopted to obtain segmented images. Meanwhile, the ViBe algorithm is adopted to obtain segmented images based on motion feature. The improved color model segmentation images and ViBe algorithm segmentation images are intersected, and the final suspected flame regions are obtained after corrosion, expansion, and region filling. Figure2 shows some segmentation examples based on the improved color model and ViBe algorithm. As shown in Figure 2, the region segmentation method combining the improved color model and ViBe algorithm can effectively exclude the land with color similar to flame and the moving pedestrians and get an accurate flame region.Figure 2
Segmentation examples based on the flame color model and ViBe algorithm: (a) original flame images; (b) segmented images with the improved color model; (c) segmented images with the ViBe algorithm; (d) segmented images with the improved color model and ViBe algorithm.
(a)(b)(c)(d)


## 2.1.1. Color Model for Segmentation

In order to describe the color distribution of flame pixels, a statistical flame color model can be established. Yan et al. [17] established a color model of flames in RGB and HSI color space. The color model overcomes the cavity inside flames to a great extent, but there is still undersegmentation of the interference with high saturation. In the study of flame image saturation, Horng et al. [18] proposed an HSI color model of flames, which restricted the saturation component. Combining the characteristics of flames in RGB and HSI color space, we adopt the flame color segmentation rules as shown in
(1)R≥B,G≥B,R≥R0,S≥S0,R≥R1,G≥G1orT1≥Th1,T2≥Th2,T2+T3≥Th3,where T1=∣R−G∣, T2=∣G−B∣, and T3=∣R−B∣. R, B, and G are the red, blue, and green color components of an image, respectively. R0 is the threshold of the red component of an image. S0 is the threshold of the saturation of an image. For a darker environment, S0=20, and a brighter environment, S0=40. R1 and G1 are the improved thresholds of the red and green components of an image, respectively. Th1, Th2, and Th3 are the thresholds of T1, T2, and T2+T3, respectively.We use the improved color model, equation (1), to separate the region in the image that meets the constraints of the color model from the background. The images collected by Chino et al. [19] were used to test the segmentation effect. Figure 1 shows a segmentation example of a flame image using different flame color models.Figure 1
Segmentation example using different flame color models: (a) original flame image; (b) segmented image with the color model in [17]; (c) segmented image with the improved color model; (d) binarized image.
(a)(b)(c)(d)From Figure1, it can be found that compared with the method in [17], the improved color model can effectively eliminate the brown-yellow wood and the illuminated ground and achieve the accurate segmentation of the flame regions.


## 2.1.2. ViBe Moving Target Segmentation

It is difficult to exclude objects whose colors are highly similar to flames only by using the color model, so it is necessary to segment moving objects based on the dynamic features of flames in a video. In the process of fire recognition, the interframe difference method [20], optical flow method [21], or background subtraction method [22] are commonly used to segment moving targets. The interframe difference method has low computational complexity, but it depends too much on the moving speed of the target. The optical flow method is computationally complex and sensitive to light. The background subtraction method is simple, and the extracted target is complete. The background subtraction method includes Gaussian mixture modeling (GMM) [23] and ViBe modeling methods [24] to establish the background statistical model. Compared with the GMM method, the ViBe algorithm randomly selects neighborhood pixel values to model or update the background according to the similarity between the neighboring pixels and does not need a lot of estimation or operation, so its time complexity to build a background model is lower. The followings are the calculation process of the ViBe algorithm:
(1)
Background model initialization. The background model initialization is the process to fill pixel sample set for building a background model. For each pixel in an image, usevix,y to represent its pixel value. Taking a certain point x,y as the center, N samples are randomly selected within a certain radius to build a sample set of the background model. The sample set vx,y can be defined as follows:(2)vx,y=v1x,y,v2x,y,⋯,vNx,y(2)
Moving target detection. For the pointx,y in an image to be tested, its pixel value mx,y is compared with each sample value in the background model. If the absolute value of the difference with a certain sample point is greater than a given threshold K0, the sample point is considered not similar to the point to be detected. If there are more than the given number K1 of sample points that are not similar to the point to be detected, the point is considered to be the foreground (moving target). Otherwise, the detected point is the background, as shown in(3)Dnx,y=1,mx,y−vnx,y>K0,0,others,(4)fx,y=1,∑n=1NDnx,y>K1,0,others,where Dnx,y represents the distance between the point to be detected and the nth sample point. fx,y represents the judgment result of background or foreground
(3)
Background model update. The ViBe algorithm uses a random updating strategy to update the background model from time to time. After a certain period of timet, the probability Pt,t+dt that a certain sample in the sample set is still retained can be defined as follows:(5)Pt,t+dt=N−1Nt+dt−tThe accuracy of region segmentation will affect feature extraction. The more accurate region segmentation is, the more extracted flame features can reflect the actual situation of flames. In the proposed hybrid method of video fire detection, color and motion features are combined for region segmentation. Based on the color distribution of flames in RGB and HSI color space, the improved color model is adopted to obtain segmented images. Meanwhile, the ViBe algorithm is adopted to obtain segmented images based on motion feature. The improved color model segmentation images and ViBe algorithm segmentation images are intersected, and the final suspected flame regions are obtained after corrosion, expansion, and region filling. Figure2 shows some segmentation examples based on the improved color model and ViBe algorithm. As shown in Figure 2, the region segmentation method combining the improved color model and ViBe algorithm can effectively exclude the land with color similar to flame and the moving pedestrians and get an accurate flame region.Figure 2
Segmentation examples based on the flame color model and ViBe algorithm: (a) original flame images; (b) segmented images with the improved color model; (c) segmented images with the ViBe algorithm; (d) segmented images with the improved color model and ViBe algorithm.
(a)(b)(c)(d)


## 2.2. Multidimensional Feature Extraction and RF Feature Selection

With the improvement of the ability of sensors to obtain information, multifeature fusion technology is widely used in the field of image recognition [25]. After region segmentation, there may still be regions that are mistakenly segmented as flames. Thus, it is necessary to extract multidimensional features such as geometry, texture, and dynamics of images and use multifeature fusion technology to achieve fire detection. However, some features are irrelevant or redundant to the recognition model, so it is necessary to select the feature subset with high discriminative ability from the multidimensional features.


### 2.2.1. Multidimensional Feature Extraction

The multidimensional features extracted from an image mainly include its circularity, aspect ratio, texture features, area change rate, flicker feature, and edge jitter feature. The followings are a brief introduction and related formulas for each of them:(1)
Circularity. Circularity reflects the degree to which the shape of the target region is close to a theoretical circle. The circularityC is calculated as(6)C=4πSL2,where S represents the area of the flame region and L represents the perimeter of the flame region
(2)
Aspect ratio. Aspect ratio reflects the stretching degree of a flame. The aspect ratioW is calculated as(7)W=EH,where E represents the width of the smallest rectangle in the flame region and H represents the length of the smallest rectangle in the flame region
(3)
Texture features. In the description of the spatial relationship of image textures, the commonly used method is based on the statistical gray-level cooccurrence matrix (GLCM) [26], which is used to calculate the representative contrast, correlation, energy, and homogeneity of texture features. Specifically, the pixel offset is set to 1, and the texture feature statistics are calculated from the GLCM at four different angles of 0°, 45°, 90°, and 135°, and then, the average value of the four directions is taken as texture feature criterion for fire recognition.The gray value of two points at a certain distance in an image is represented byi,j. Suppose Pi,j is the probability of the gray value i,j. The formula of its contrast f1, correlation f2, energy f3, and homogeneity f4 of the image is as follows:
(8)f1=∑i=1K∑j=1Ki−j2Pi,j,f2=1σxσy∑i=1K∑j=1KijPi,j−μxμy,f3=∑i=1K∑j=1KP2i,j,f4=∑i=1K∑j=1KPi,j1+i−j2,where K represents the gray level of an image. μx and μy represent the mean value of Pi,j in row and column, respectively. σx and σy represent the standard deviation of Pi,j in row and column, respectively
(4)
Area change rate. Area change rate represents the area change of a flame region. The area change rate∆S is calculated as(9)△S=Sn−Sn−1Sn−1,n≥2,where Sn represents the area of the flame region in the current frame and Sn−1 represents the area of the flame region in the previous frame
(5)
Flicker feature. Flame flicker will cause the image pixels to change from nonflame to flame. In order to effectively reflect the flicker characteristics of a flame without increasing the complexity of the algorithm, the change amplitude of the flame foreground is used to characterize the flicker feature of the flame. The flicker feature∆F is calculated as(10)△F=Sn∩S̄n−1∪Sn−1∩S̄nSn,n≥2(6)
Edge jitter feature. Edge jitter measures the degree of the edge change of an object in the process of deformation. The edge jitter feature∆L is calculated as(11)△L=Ln−Ln−1Ln−1,n≥2,where Ln represents the perimeter of the flame region of the current frame and Ln−1 represents the perimeter of the flame region of the previous frame


### 2.2.2. Random Forest Feature Selection

Random forest (RF) [27] is an integrated machine learning method that uses decision tree as the basic learner and makes decision through voting mechanism. For feature selection, the importance of a single feature variable is calculated by the RF method, and then finding the feature variables that are highly related to the dependent variable. Thus, we can select a small number of feature variables which can fully guarantee the accuracy of the prediction results.The purpose of feature selection is to select the relevant feature subset from the existing feature set. After feature extraction on the suspected flame region, we can get a 9-dimensional feature vectorCWf1f2f3f4∆S∆F∆L. We use the RF method to select the features with a strong correlation with the actual results as the input of the BP neural network model.Since there is no published standard dataset in the field of fire prevention and detection at present, we mainly use a series of typical databases proposed in [28–30] to build our video set. Our video set includes 30 fire videos and 10 interference videos. Fire videos mainly include different shapes of flames in indoor, highway, and forest scenes. Interference videos mainly include street lights, car lights, and red objects. The resolution of the videos is uniformly adjusted to 1280×720, and 20 consecutive frames of images are selected from each video to form a sample dataset. The sample dataset has a total of 800 images, some of which are shown in Figure 3.Figure 3
Some images of the sample dataset.In this paper, the suspected flame regions are segmented on the sample dataset and the multidimensional features of the flame are extracted. The RF feature importance is calculated based on the Scikit-learn tool in the Python machine learning library. Specifically, the number of decision trees in the RF is set to 100, and the maximum depth of the decision trees is set to unlimited. The minimum number of samples required to split an internal node is set to 2; the minimum number of samples required to be at a leaf node is set to 1. The measurement criterion of split quality is set to mean square error (MSE). The ranking of the feature importance is given in Figure4. From Figure 4, it can be found that flicker feature has the highest ranking and edge jitter feature has the lowest ranking.Figure 4
Feature importance ranking.According to the ranking in Figure4, the flame features are divided into combined features F1-F9, which, respectively, represent ∆F, f1∆F, Cf1∆F, CWf1∆F, CWf1f3∆F, CWf1f3f4∆F, CWf1f2f3f4∆F, CWf1f2f3f4∆S∆F, and CWf1f2f3f4∆S∆F∆L. The BP neural network method is used for training and classification, and the correct classification results of each combination feature are given in Figure 5. The correct classification rate is the average of 10 prediction results.Figure 5
Combination feature classification results.According to the classification results of the combined features as shown in Figure5, the correct classification rate of samples reaches a high level starting from the 5th combined feature, F5, and with the increase of features, the correct classification rate of samples tends to be stable. To avoid interference caused by excessive features and ensure the accuracy of classification results, the 5th combined feature, F5, is selected for fire recognition, which includes circularity, aspect ratio, contrast, energy, and flicker feature.


## 2.2.1. Multidimensional Feature Extraction

The multidimensional features extracted from an image mainly include its circularity, aspect ratio, texture features, area change rate, flicker feature, and edge jitter feature. The followings are a brief introduction and related formulas for each of them:(1)
Circularity. Circularity reflects the degree to which the shape of the target region is close to a theoretical circle. The circularityC is calculated as(6)C=4πSL2,where S represents the area of the flame region and L represents the perimeter of the flame region
(2)
Aspect ratio. Aspect ratio reflects the stretching degree of a flame. The aspect ratioW is calculated as(7)W=EH,where E represents the width of the smallest rectangle in the flame region and H represents the length of the smallest rectangle in the flame region
(3)
Texture features. In the description of the spatial relationship of image textures, the commonly used method is based on the statistical gray-level cooccurrence matrix (GLCM) [26], which is used to calculate the representative contrast, correlation, energy, and homogeneity of texture features. Specifically, the pixel offset is set to 1, and the texture feature statistics are calculated from the GLCM at four different angles of 0°, 45°, 90°, and 135°, and then, the average value of the four directions is taken as texture feature criterion for fire recognition.The gray value of two points at a certain distance in an image is represented byi,j. Suppose Pi,j is the probability of the gray value i,j. The formula of its contrast f1, correlation f2, energy f3, and homogeneity f4 of the image is as follows:
(8)f1=∑i=1K∑j=1Ki−j2Pi,j,f2=1σxσy∑i=1K∑j=1KijPi,j−μxμy,f3=∑i=1K∑j=1KP2i,j,f4=∑i=1K∑j=1KPi,j1+i−j2,where K represents the gray level of an image. μx and μy represent the mean value of Pi,j in row and column, respectively. σx and σy represent the standard deviation of Pi,j in row and column, respectively
(4)
Area change rate. Area change rate represents the area change of a flame region. The area change rate∆S is calculated as(9)△S=Sn−Sn−1Sn−1,n≥2,where Sn represents the area of the flame region in the current frame and Sn−1 represents the area of the flame region in the previous frame
(5)
Flicker feature. Flame flicker will cause the image pixels to change from nonflame to flame. In order to effectively reflect the flicker characteristics of a flame without increasing the complexity of the algorithm, the change amplitude of the flame foreground is used to characterize the flicker feature of the flame. The flicker feature∆F is calculated as(10)△F=Sn∩S̄n−1∪Sn−1∩S̄nSn,n≥2(6)
Edge jitter feature. Edge jitter measures the degree of the edge change of an object in the process of deformation. The edge jitter feature∆L is calculated as(11)△L=Ln−Ln−1Ln−1,n≥2,where Ln represents the perimeter of the flame region of the current frame and Ln−1 represents the perimeter of the flame region of the previous frame


## 2.2.2. Random Forest Feature Selection

Random forest (RF) [27] is an integrated machine learning method that uses decision tree as the basic learner and makes decision through voting mechanism. For feature selection, the importance of a single feature variable is calculated by the RF method, and then finding the feature variables that are highly related to the dependent variable. Thus, we can select a small number of feature variables which can fully guarantee the accuracy of the prediction results.The purpose of feature selection is to select the relevant feature subset from the existing feature set. After feature extraction on the suspected flame region, we can get a 9-dimensional feature vectorCWf1f2f3f4∆S∆F∆L. We use the RF method to select the features with a strong correlation with the actual results as the input of the BP neural network model.Since there is no published standard dataset in the field of fire prevention and detection at present, we mainly use a series of typical databases proposed in [28–30] to build our video set. Our video set includes 30 fire videos and 10 interference videos. Fire videos mainly include different shapes of flames in indoor, highway, and forest scenes. Interference videos mainly include street lights, car lights, and red objects. The resolution of the videos is uniformly adjusted to 1280×720, and 20 consecutive frames of images are selected from each video to form a sample dataset. The sample dataset has a total of 800 images, some of which are shown in Figure 3.Figure 3
Some images of the sample dataset.In this paper, the suspected flame regions are segmented on the sample dataset and the multidimensional features of the flame are extracted. The RF feature importance is calculated based on the Scikit-learn tool in the Python machine learning library. Specifically, the number of decision trees in the RF is set to 100, and the maximum depth of the decision trees is set to unlimited. The minimum number of samples required to split an internal node is set to 2; the minimum number of samples required to be at a leaf node is set to 1. The measurement criterion of split quality is set to mean square error (MSE). The ranking of the feature importance is given in Figure4. From Figure 4, it can be found that flicker feature has the highest ranking and edge jitter feature has the lowest ranking.Figure 4
Feature importance ranking.According to the ranking in Figure4, the flame features are divided into combined features F1-F9, which, respectively, represent ∆F, f1∆F, Cf1∆F, CWf1∆F, CWf1f3∆F, CWf1f3f4∆F, CWf1f2f3f4∆F, CWf1f2f3f4∆S∆F, and CWf1f2f3f4∆S∆F∆L. The BP neural network method is used for training and classification, and the correct classification results of each combination feature are given in Figure 5. The correct classification rate is the average of 10 prediction results.Figure 5
Combination feature classification results.According to the classification results of the combined features as shown in Figure5, the correct classification rate of samples reaches a high level starting from the 5th combined feature, F5, and with the increase of features, the correct classification rate of samples tends to be stable. To avoid interference caused by excessive features and ensure the accuracy of classification results, the 5th combined feature, F5, is selected for fire recognition, which includes circularity, aspect ratio, contrast, energy, and flicker feature.


## 2.3. Construction of the BP Neural Network Model

The BP neural network [31] is also called error back propagation neural network. Because the weights of neurons in adjacent layers are interrelated, the network has a nonlinear mapping ability to solve complex problems. Considering the simplicity and practicability, a three-layer BP neural network with one input layer, one hidden layer, and one output layer is constructed for multifeature fusion and fire recognition.The number of nodes in the input layer of the BP neural network depends on the dimension of the feature vector. In this paper, five features of each fire image are selected to form the feature vectorCWf1f3∆F, so there are 5 nodes in the input layer. The output layer outputs the recognition result, so there is 1 node. The normalized output value ranges from [0, 1], and when the output value belongs to [0, 0.5), it means nonflame. When the output value belongs to [0.5, 1], it is expressed as flame. The number of hidden layer nodes is calculated using empirical equation (12), in which, m and n represent the number of nodes in the input layer and output layer, respectively, and a is a constant between [1, 10]. Through repeated experiments, it is found that when the number of the hidden layer nodes h is 10, the neural network achieves the optimal training effect.
(12)h=m+n+a.Based on above analysis, the structure of the BP neural network constructed in this paper is given in Figure6. The BP neural network model will be used for fire recognition in the following section.Figure 6
Structure diagram of the constructed BP neural network.


## 3. Experiments and Results Analysis

### 3.1. Experimental Environment

The experimental environment is Windows 10 operating system, 8 GB memory, Intel (R) core (TM) i5-10500 CPU @ 3.10 GHz, MATLAB 2018a platform.


### 3.2. Detection Process

The process of video fire detection in this paper is given in Figure7.Figure 7
Video fire detection process.


### 3.3. Training and Experiments

The sample dataset of the training set and the test set is divided based on typical standards of 70% and 30%. The division is given in Table1. Specifically, the maximum number of epochs is set to 2000. The Levenberg-Marquardt (LM) algorithm is selected as the learning algorithm, and the learning rate is set to 0.001. MSE is used as the loss function, and the minimum value of the loss function is set to 0.01. The neural network training performance is shown in Figure 8. From Figure 8, it can be found that the value of the loss function gradually decreases during the training process and reaches the minimum value of the set loss function at 30 epochs.Table 1
The division of sample dataset.
ClassTraining samplesTest samplesTotalFlame images420180600Interfering images14060200Figure 8
Neural network training performance.After neural network training is completed, the correct classification rate on the test sample set is 96.67%. In order to further verify the performance of the fire detection method, five videos that have not participated in the training are selected to test the trained neural network model, including three fire videos and two interference videos. The experimental video sets are shown in Figure9. The descriptions of the experimental videos are shown in Table 2.Figure 9
Experimental video sets.Table 2
Experimental video description.
VideoNumber of framesNumber of flame framesVideo descriptionvideo1758758Fire video. The ground color is highly similar to a flame.video2352352Fire video. There is strong light and shaking branches.video3140140Fire video. There are two workers walking around with torches.video42980Interference video. There are car lights interference.video51500Interference video. There are car lights and pedestrian interference.


### 3.4. Results Analysis

The combined RF feature selection and BP neural network method (abbreviated as RF-BP) and the directly performed BP neural network method (abbreviated as Dir-BP) are used to do tests with several experimental videos. Furthermore, the two proposed methods are compared with the fire recognition method in [11, 13]. The accuracy, precision, recall, and F-score are used to evaluate the effect on fire recognition [32], as shown in
(13)Accuracy=TP+TNTP+TN+FP+FN,(14)Precision=TPTP+FP,(15)Recall=TPTP+FN,(16)F‐score=2∗Precision∗RecallPrecision+Recall,where TP represents the number of correctly classified frames of the fire videos. TN represents the number of correctly classified frames of the interference videos. FN represents the number of misclassified frames of the fire videos. FP represents the number of misclassified frames of the interference videos.The fire recognition result is determined by the output value of BP neural network. The experimental results are given in Table3, and the recognition effect evaluation is given in Table 4.Table 3
Experimental results.
MethodTPTNFNFPSVM [11]1109102141346BP [13]91037634072Dir-BP (ours)11904106038RF-BP (ours)12134213727Table 4
Evaluation of recognition effect.
MethodAccuracyPrecisionRecallF-scoreSVM [11]0.7130.7620.8870.820BP [13]0.7570.9270.7280.815Dir-BP (ours)0.9420.9690.9520.961RF-BP (ours)0.9620.9780.9700.970For the scene in Figure9, the lights and the ground illuminated by the lights may be segmented into suspected flame areas. In [11], the shape change and centroid displacement of flame are concerned, and the recognition of fire images was realized by support vector machine. Since the lights follow the movement of the vehicle in interference videos, the ground illuminated by the lights has dynamic features similar to flames. This method did not perform well in interference videos (video4 and video5) according to the results in Table 3. In [13], the recognition of fire images was realized by the fusion of Y, Cb, and Cr components in YCbCr color space. There were too many false detection frames in fire videos (video1, video2, and video3) according to the results in Table 3. This shows that using only the color features of flames as a criterion, it is difficult to distinguish the interference of objects similar to the flame color in the background. Compared with the method in [11, 13], the proposed Dir-BP method directly performs BP neural network fusion, in which the extracted features include 9-dimensional features and are not selected. Since the texture and dynamic features of the flames are considered, this method has a certain degree of improvement in accuracy, precision, recall, and F-score according to the results in Table 4. However, due to the features with small correlation that may interfere with the recognition results, the number of false detection frames is still large. The proposed RF-BP method with the combination of RF feature selection and BP neural network makes full use of the geometric features, texture features, and dynamic features of flames, which can effectively avoid some feature interferences and perform the best in the evaluation indexes.


## 3.1. Experimental Environment

The experimental environment is Windows 10 operating system, 8 GB memory, Intel (R) core (TM) i5-10500 CPU @ 3.10 GHz, MATLAB 2018a platform.


## 3.2. Detection Process

The process of video fire detection in this paper is given in Figure7.Figure 7
Video fire detection process.


## 3.3. Training and Experiments

The sample dataset of the training set and the test set is divided based on typical standards of 70% and 30%. The division is given in Table1. Specifically, the maximum number of epochs is set to 2000. The Levenberg-Marquardt (LM) algorithm is selected as the learning algorithm, and the learning rate is set to 0.001. MSE is used as the loss function, and the minimum value of the loss function is set to 0.01. The neural network training performance is shown in Figure 8. From Figure 8, it can be found that the value of the loss function gradually decreases during the training process and reaches the minimum value of the set loss function at 30 epochs.Table 1
The division of sample dataset.
ClassTraining samplesTest samplesTotalFlame images420180600Interfering images14060200Figure 8
Neural network training performance.After neural network training is completed, the correct classification rate on the test sample set is 96.67%. In order to further verify the performance of the fire detection method, five videos that have not participated in the training are selected to test the trained neural network model, including three fire videos and two interference videos. The experimental video sets are shown in Figure9. The descriptions of the experimental videos are shown in Table 2.Figure 9
Experimental video sets.Table 2
Experimental video description.
VideoNumber of framesNumber of flame framesVideo descriptionvideo1758758Fire video. The ground color is highly similar to a flame.video2352352Fire video. There is strong light and shaking branches.video3140140Fire video. There are two workers walking around with torches.video42980Interference video. There are car lights interference.video51500Interference video. There are car lights and pedestrian interference.


## 3.4. Results Analysis

The combined RF feature selection and BP neural network method (abbreviated as RF-BP) and the directly performed BP neural network method (abbreviated as Dir-BP) are used to do tests with several experimental videos. Furthermore, the two proposed methods are compared with the fire recognition method in [11, 13]. The accuracy, precision, recall, and F-score are used to evaluate the effect on fire recognition [32], as shown in
(13)Accuracy=TP+TNTP+TN+FP+FN,(14)Precision=TPTP+FP,(15)Recall=TPTP+FN,(16)F‐score=2∗Precision∗RecallPrecision+Recall,where TP represents the number of correctly classified frames of the fire videos. TN represents the number of correctly classified frames of the interference videos. FN represents the number of misclassified frames of the fire videos. FP represents the number of misclassified frames of the interference videos.The fire recognition result is determined by the output value of BP neural network. The experimental results are given in Table3, and the recognition effect evaluation is given in Table 4.Table 3
Experimental results.
MethodTPTNFNFPSVM [11]1109102141346BP [13]91037634072Dir-BP (ours)11904106038RF-BP (ours)12134213727Table 4
Evaluation of recognition effect.
MethodAccuracyPrecisionRecallF-scoreSVM [11]0.7130.7620.8870.820BP [13]0.7570.9270.7280.815Dir-BP (ours)0.9420.9690.9520.961RF-BP (ours)0.9620.9780.9700.970For the scene in Figure9, the lights and the ground illuminated by the lights may be segmented into suspected flame areas. In [11], the shape change and centroid displacement of flame are concerned, and the recognition of fire images was realized by support vector machine. Since the lights follow the movement of the vehicle in interference videos, the ground illuminated by the lights has dynamic features similar to flames. This method did not perform well in interference videos (video4 and video5) according to the results in Table 3. In [13], the recognition of fire images was realized by the fusion of Y, Cb, and Cr components in YCbCr color space. There were too many false detection frames in fire videos (video1, video2, and video3) according to the results in Table 3. This shows that using only the color features of flames as a criterion, it is difficult to distinguish the interference of objects similar to the flame color in the background. Compared with the method in [11, 13], the proposed Dir-BP method directly performs BP neural network fusion, in which the extracted features include 9-dimensional features and are not selected. Since the texture and dynamic features of the flames are considered, this method has a certain degree of improvement in accuracy, precision, recall, and F-score according to the results in Table 4. However, due to the features with small correlation that may interfere with the recognition results, the number of false detection frames is still large. The proposed RF-BP method with the combination of RF feature selection and BP neural network makes full use of the geometric features, texture features, and dynamic features of flames, which can effectively avoid some feature interferences and perform the best in the evaluation indexes.


## 4. Conclusion

In this paper, an effective video fire detection hybrid method based on RF feature selection and BP neural network is proposed. The improved color model and ViBe algorithm are used to segment the suspected flame regions, and the RF importance analysis method is used for the feature combination and selection. Multidimensional features of flames are extracted from the suspected regions, and these extracted features are combined and selected according to the RF feature importance analysis. In addition, a BP neural network model is built for multifeature fusion to determine the fire recognition result. Experimental results show that the features extracted by this RF-BP hybrid approach can effectively avoid the interference caused by the features with small correlation and can well complete the fire detection of experimental videos in different scenes.The proposed method will be further investigated and have a possible application for fire recognition in video surveillance and detection robots. Considering that the performance of the BP neural network model is easily affected by the sample dataset, the next step is to expand the existing dataset to make the features covered by the training samples with more comprehensive information.



---

*Source: 5160050-2022-01-05.xml*