# Deep Learning Semantic Segmentation for Water Level Estimation Using Surveillance Camera
## 2 Methodology
### Water Level Observation
#### 2.5.2 Water Level Framework  
A deep learning architecture network that obtained higher accuracy results was then be used for flood detection applications. The model was applied to images captured by a surveillance camera that was installed in the study area. Water body regions from the segmentation results were extracted and converted into binary masks before undergoing the post-processing stage to enhance the meaningful feature. The first morphological operation was to remove small objects from the binary image. It is assumed that the water region was one connected component, hence, small objects with less than 100,000 pixels were erased. Next, morphological closing was performed on the binary image to smooth the edges and close any open holes that were specified at a radius of 2 pixels. The last morphological operation is to fill holes in the interior of the water feature. Figure 4: The yellow camera icon represents the location of the surveillance camera that was used for water detection using semantic segmentation (Image courtesy: Google Earth). In order to obtain water level information, terrestrial light detection and ranging (LiDAR) was used in this study as it can provide a high-resolution digital elevation model (DEM) and has been widely applied in flood studies [26]. Field data collection for LiDAR was done once during the normal water condition (Figure 5). Several elevation points were extracted from LiDAR data as water level markers based on on-site references during data collection and the marker locations were also identified in surveillance images prior to the segmentation process. The extraction of elevation values was done in geographical information system (GIS) environment by using ArcGIS 10.2.2 software. To replicate this work, it is suggested to replace LiDAR data with a global navigation satellite system (GNSS) with centimeter accuracy. The elevation values of the markers were then overlaid with the post-processed water region to get the idea of how depth the water levels are as shown in Figure 5. Four water level markers represent different water level thresholds used in this study. Green '\(\times\)' represents normal level, yellow '\(\times\)' represents alert level, and orange and red '\(\times\)' represent warning and danger levels, respectively, and elevation for each point was identified. River water levels were estimated based on the elevation from each marker by computing the average elevations of two water thresholds, if possible. For instance, if the water region covered the area between normal and alert markers, the mean elevations of both water thresholds were calculated to estimate the water level for that particular condition. If the water region was covered up to only one marker, then the water level followed the elevation value of the particular marker. On the other hand, when the water region was less than the normal threshold or exceeded the danger threshold, this study did not have absolute values yet, as there was limited information regarding the elevations at these levels during the validation stage. Since there is no water level sensor in the study area, the proposed approach was used in another location equipped with a water level sensor to validate the water level estimation. The relationship between the estimated water level and water level measured by the sensor was evaluated by using Spearman's rank-order correlation coefficient [69]. It is a nonparametric test to identify the strength and direction of a monotonic relationship between two sets of continuous or ordinal data. Equation (5) was used for computing the rank correlation with ties rank. \[\rho=1-6\left[\frac{\Sigma D^{2}+\frac{m_{i}^{3}-m_{i}}{12}+\ldots}{n(n^{2}-1 )}\right] \tag{5}\]  
Figure 5: Water level markers were extracted from LiDAR data during normal conditions. where \(D\) is the difference between ranks, \(n\) is the number of pairs of data, and \(m_{i}\) is the number of repetitions of \(ith\) rank.