Combining Spectral Water Indices and Mathematical Morphology to Evaluate Surface Water Extraction in Taiwan

: Rivers in Taiwan are characterised by steep slopes and high sediment concentrations. Moreover, with global climate change, the dynamics of channel meandering have become complicated and frequent. The primary task of river governance and disaster prevention is to analyse river changes. Spectral water indices are mostly used for surface water estimation, which separates the water from the background based on a threshold value, but it can be challenging in the case of environmental noise. Edge detection uses a canny edge detector and mathematical morphology for extracting geometrical features from the image and effective edge detection. This study combined spectral water indices and mathematical morphology to capture water bodies based on downloaded remote sensing images. From the ﬁndings, this study summarised the applicability of various spectral water body indices to the surface water extraction of different river channel patterns in Taiwan. The normalised difference water index and the modiﬁed normalised difference water index are suitable for braided rivers, whereas the automated water extraction index is ideal for meandering rivers.


Introduction
Taiwan is a narrow (north-south) island, with rivers following an east-west flow and having shorter flow path characteristics compared with other countries. Most of Taiwan's rivers originate in high mountain areas; therefore, they have high flow rates and steep slopes [1]. Moreover, Taiwan is known for extreme weather events. A complex, seasonally shifting, monsoon-dominated weather system brings an abundance of rain, with a yearly average rainfall of 1000-3000 mm [2]. Because of the effects of extreme weather in recent years and the scale and frequency of rain events, the number of rainfall-related landslides and injuries has significantly increased [1]. Such weather causes the water flow to have a high sand content, which leads to intense riverbed silting. River sand mining and the construction of cross-river structures have also made river changes more frequent and complex. The prevention and control of river disasters have become critical tasks for the government. Therefore, analysing and investigating river changes must be prioritised [3,4].
In the past, river change patterns were the primary data source for river planning and management; traditional measurement techniques included control, topographic, and cross-sectional surveys [5]. River cross-sectional survey data have helped researchers to understand the actual changes in river troughs. Much effort, time, and money are required when short-term information on river changes cannot be obtained. Remote sensing data have the following characteristics: a synoptic view, the potential for remeasurement, and a wide range of spatial and temporal resolutions. The format of remote sensing data is suitable for computer processing; combined with their other advantages, this has made such data the primary source for change detection [6][7][8]. Remote sensing images include multispectral information and the band data of different ground objects can be collected for feature classification [9]. Hence, this study selected remote sensing images as a data source for river extraction. First, the inspection of river channel change is necessary for determining the characteristics of water bodies. Most water extraction methods are based on remote sensing images. Methods for determining water characteristics include supervised classification, nonsupervised classification [10,11], mixed cell decomposition [12][13][14], single-band threshold, and spectral water indices [15][16][17][18]. Spectral water indices have higher accuracy and convenience compared with other methods [19,20]. The fundamental water index normalized difference water index (NDWI) using green and near-infrared (NIR) bands of a Landsat thematic mapper (TM) image maximize water feature identification by McFeeters [16]. Xu replaced the near-infrared (NIR) band in McFeeters's NDWI with the shortwave infrared (SWIR) band and derived the modified NDWI (MNDWI) [18] to resolve water bodies over built-up areas. However, there were still significant problems due to shadows in mountainous terrain. Feyisa et al. [15] proposed the automated water extraction index (AWEI) to identify water features, which has two conditions: AWEIsh is designed primarily to remove shadow pixels, whereas AWEInsh is designed for areas with an urban background. Extracting rivers and lakes by combining the water indices (NDWI, MNDWI, AWEIsh, and AWEInsh) was proposed as an automated method with digital image processing techniques in Landsat scenes in China [21]. Hence, in this study, we evaluated the performance of the most widely used water indices: NDWI, MNDWI, AWEIsh, and AWEInsh in a Landsat image of Taiwan. Mathematical morphology can be used to extract water body features, and it has the advantage of noise filtering and feature information retention. In particular, a continuous shape can be maintained for narrow water bodies in space [22].
The water body index and mathematical morphology have their advantages in water body extraction from images. This study combined the benefits of these two methods to extract water bodies. The spectral water body indices of the images in each period were calculated to enhance the differences between the water body and other objects. Then, a series of mathematical morphological operations were performed, and the characteristics of the water body were extracted. Subsequently, this study analysed the optimal water body index corresponding to different river channel patterns in Taiwan.

Data
The satellite optical images are free to download, and have regular fixed-point shooting and more spectral resolution options. This study used Landsat imagery from the United States as a source of information for detecting river changes. The data product, Level-1 TP, was downloaded from the U.S. Geological Survey (USGS). Landsat-7 was launched by NASA on 15 April 1999, with enhanced theme mapping (Enhanced Thematic Mapper Plus (ETM plus)) sensors in eight bands. Landsat-8 was launched by NASA on 11 February 2013 and is equipped with a land imager (OLI) and thermal infrared sensor (Thermal InfraRed Sensor (TIRS)) with 11 bands.
Taiwan has 26 main rivers. This study selected rivers of different types and locations: the Tamsui River in Northern Taiwan, the Beigang River in Central Taiwan, the Zengwen River and Qishan River in Southern Taiwan, and the Xiuguluan River in Eastern Taiwan. River change was the primary target of this study; for every testing area, images recorded at different times were used for detecting changes ( Figure 1 and Table 1).

Method
This study's primary goal was to identify water bodies from remote sensing images for use in flood prevention and river management. The research steps were as follows: First, the spectral water body indices of the remote sensing images of each period were calculated to enhance the difference between water bodies and other earth objects. Then, a series of mathematical morphological operations were conducted to extract the water body features. A flow chart of the research process is presented in Figure 2.

Spectral Water Indices
Spectral water indices are algebraic operations that combine two or more bands to enhance the difference between water bodies and nonwater bodies. Then, appropriate thresholds are established to distinguish between water bodies and other land covers; the process is simple, fast, and low-cost, especially for treating specific noise. Spectral water indices are widely used to identify water bodies [19,20]. We used four typical spectral water body indices for water body extraction in this study: the normalised difference water index (NDWI), the modified NDWI (MNDWI), the automated water extraction index shadow (AWEIsh), and the automated water extraction index no shadow (AWEInsh; see Table 2). Table 2. Spectral water indices for water feature extraction.

Spectral Water Index Equation
Normalised difference water index (NDWI) Automated water extract index shadow (AWEIsh) Automated water extract index no shadow (AWEInsh) In the surface water extraction process, the threshold of 0 is used for all individual index maps. An optimum threshold is searched to give the highest overall accuracy and kappa coefficient based on the trial and error method. Furthermore, indices with better extraction abilities are combined to increase the separability between water and non-water surfaces based on the evaluation matrices [21].

Mathematical Morphology
Edges are important features in an image since they represent significant local intensity changes. They provide important clues to separate regions within an object or to identify changes. Most remote sensing applications, such as image registration, image segmentation, region separation, object description, and recognition, use edge detection as a preprocessing stage for feature extraction. Real images, such as remote sensing images, can be corrupted by point noise [23,24]. Edge detection uses a canny edge detector and mathematical morphology for extracting geometrical features from the image and for effective edge detection [25]. After data preprocessing and spectral water body index calculations, the images were processed using mathematical morphology. Mathematical morphology is an image processing technique that was proposed by Matheron and applied by Serra to image processing and analysis [26]. Compared with traditional classification, which only considers the grayscale value of pixels, mathematical morphology also considers the shape, neighbourhood, size, and other characteristics of an object to preserve its shape and edges. This is particularly suitable for water bodies with specific spatial features, resulting in feature extraction [27]. Mathematical morphology is highly effective at distinguishing between water and nonwater bodies. For example, KuPidura used mathematical morphology to distinguish between lakes and rivers and proved that mathematical morphology results are accurate [28]. Sghaier et al. combined image texture with mathematical morphology to form an algorithm for extracting rivers from high-spatial-resolution images [22]. Rishikeshan and Ramesh developed a mathematical-morphology-based semiautomated lake extraction method that preserves the actual size and shape of lakes and ponds [29]. Intervention studies involving animals or humans, and other studies that require ethical approval, must list the authority that provided approval and the corresponding ethical approval code.
This study used Matlab toolsto operate mathematical morphology [30]. Median filtering is the first step, which is a nonlinear operation often used in image processing to reduce salt and pepper noise. It makes the image smoother and intensifies pixels, mainly background pixels close to each other. The second step is to determine the size of the structural elements, which depends on satellite imagery at different spatial resolutions (15 m in this study). The third and fourth steps are dilation and erosion operating "lengthening", "thickening", "shrinks", and "thins" in the binary image, which achieve control by a structural element. The last two steps are opening and closing operations. The opening operation makes the contour of objects smooth and disconnects narrow discontinuous, and removes thin protrusions. Similarly, with the opening operation, the closing operation also makes the outline smooth. The opposite is that it usually eliminates discontinuity and narrows long, thin gaps; clears up small holes; and fills the ruptures of the contour line. (For theoretical principles and foundations, please refer to [31]).

Accuracy Assessment
After all the research procedures, the water body results were compared with reference images (i.e., the ground truth data). To verify the accuracy of the results, the reference images were recorded at the same time as the result images. In this study, the reference data of water bodies and nonwater bodies in colour images were collected through random sampling to evaluate the accuracy of the classification results. Landsat 8 colour images were used as reference images, and random sampling was used to collect reference data on water and nonwater bodies. Sampling points were established using ArcGIS software, in which random sampling methods comprise the following options: 1.
Simple random sampling: The samples are randomly distributed throughout the image.

2.
Stratified random sampling: A random number of samples is distributed throughout the image; the number of samples for each category is proportional to the area of the image.

3.
Equalised stratified random sampling: A randomly distributed sample count is created throughout the image, with each category having the same sample size.
The interest category of the topographic features was the water bodies. To ensure accurate and reliable classification, images were selected in which water bodies accounted for a lower proportion of the whole image compared with other objects. Hence, we used equalised stratified random sampling to produce sampling points. The water body and nonwater sample sizes were the same to avoid the sample number being concentrated in the nonwater body category. For each category, a sufficient number of samples must be collected to accurately assess the classification accuracy when using random sampling. However, a crucial consideration is the number of sampling points, which must be determined to balance accuracy with the cost of collecting reference data. In general, at least 50 random samples are required for each category when the study area is less than 1 million acres and there are fewer than 12 categories [32]. At least 75-100 random samples should be collected in each category when the study area is large or the surface distribution is more complex (100 samples in this study). These criteria were verified as statistically valid and helpful.
In this study, a confusion matrix was used as an evaluation indicator, the results of which can be divided into four categories, as presented in Table 3: (1) True positive (TP) represents correctly identified water pixels; (2) True negative (TN) indicates the correctly rejected nonwater pixels; (3) False positive (FP) indicates incorrectly identified water pixels; (4) False negative (FN) indicates undetected water pixels. The values in the confusion matrix can be used to calculate the producer accuracy (PA), user accuracy (UA), overall accuracy (OA), and kappa coefficient, which are detailed in Table 4. Table 4. Indicators in the accuracy evaluation.

Accuracy Evaluation Metrics Equation Description
Producer accuracy PA = TP TP+FN The ratio of the correctly classified pixels to the actual total number of pixels for each category.
User accuracy UA = TP TP+FP The ratio of the correctly classified pixels to the total pixels categorised for each category.
Overall accuracy OA = TP+TN T The ratio of the correctly classified pixels to the total number of pixels.

Kappa coefficient
The percentage of errors reduced by classification results compared with completely random classifications.
In Table 4, ∑ is the chance accuracy represented by (TP + FP)(TP + FN) + (FN + TN)(FP + TN), where T is the total number of pixels. The accuracy indices of PA, UA, and OA range from 0 to 1, with values closer to 1 indicating more accurate results. However, these indices do not account for random agreement between datasets. Hence, the kappa coefficient, a tool for controlling the random agreement factor, is often used with PA, UA, and OA. Usually, the kappa coefficient can range from −1 to +1, where 0 represents the agreement that is expected from random chance, and 1 represents perfect agreement between the raters [33].

Element Sizes in Water Body Extraction
An image's spatial resolution affects the sizes of structural elements when the characteristics of water bodies are extracted using spectral water body indices combined with mathematical morphology; specifically, Landsat images with a spatial resolution of 15 m were used in this study. Because morphological operators are based on minimum/maximum computations, they require a total ordering relationship between the values of the pixels falling within the neighbourhood defined by the structuring element. This study used three consecutive years (2013 to 2015) of image data from the Beigang River area to find the most suitable structural element size, which also calculates OA of each water index; the results are presented in Table 5 and Figure 3.  With a structural element size of three, the Beigang River water body was entirely extracted using mathematical morphology. However, some smaller pixels were misjudged as water bodies, as indicated by the circles in Figure 3. The accuracy of each spectral water index was higher than those of other structural element sizes. The Beigang River could also be fully extracted when the structural element size was four. When the structural element size was five, however, water bodies were determined to be nonwater, as indicated by the circles in Figure 3. In summary, for extracting water bodies using water body indices combined with mathematical morphology, the most suitable structural element size was four.

Results of Water Body Extraction
The original images were processed using radiation correction, atmospheric correction, and image fusion. NDWI, MNDWI, AWEIsh, and AWEInsh were used to calculate and enhance the differences between water bodies and nonwater bodies in the images. Subsequently, mathematical morphological calculations were performed, and the water features were finally extracted. The accuracy of water body classification was supplemented by Google Earth images with an accuracy assessment and confusion matrix through random sampling. The total number of samples collected was 100. Then, the PA, UA, OA, and kappa coefficient were calculated based on the confusion matrix of the four spectral water body indices. The OA and kappa coefficient were then used as evaluation criteria to determine the quality of the classification results.

1.
Tamsui River As indicated in Table 6, the MNDWI performed the best in terms of OA for the Tamsui River watershed. MNDWI, using an MIR band instead of an NIR band, can considerably improve the enhancement in open water features. It can quickly and accurately discriminate water from nonwater features [18]. Based on the results, the MNDWI is particularly suitable for urban areas with both buildings and water bodies. It can enhance the differences between artificial objects and water bodies to avoid misjudgements, as shown in Figure 4.

2.
Beigang River The AWEI indices were optimal for the Beigang River in terms of OA ( Table 7). The studied area is located in the downstream plain, with less shadow-free problems. AWEIsh could not fully depict tributaries and buildings, which it misjudged as water bodies; therefore, the AWEInsh is more suitable for the Beigang River ( Figure 5).

Zengwen River
In terms of OA in the Zengwen River basin, the AWEI indices had the best performance ( Table 8). The study area includes downstream plains and midstream areas of hillsides. When the water extraction results were examined, this study found that AWEIsh could show continuous water flows and contributed to the analysis of subsequent change detection ( Figure 6).

Qishan River
The Qishan River is located in an upstream area with mostly mountainous terrain and only a few artificial buildings. In terms of OA, the NDWI exhibited the best performance for the Qishan River (Table 9). Based on the water extraction results, the NDWI successfully distinguished between water bodies and other objects, and then fully extracted the river channel of the Qishan River, as detailed in Figure 7.

5.
Xiuguluan River Similar to the Qishan River, the Xiuguluan River is mostly located in mountainous areas. In addition to artificial buildings, there are ponds and agricultural land. As detailed in Table 10, the NDWI had the best performance in terms of OA for the Xiuguluan River. Based on the water extraction results, the NDWI eliminated the mountain shadow problem, as detailed in Figure 8.      6. Zengwen River-Results of spectral water body indices in terms of water body extraction at different times.

Result of River Changing
The findings of this study were used to detect river changes between two epochs in the testing areas. It is easy to see the difference between epochs, based upon which river management and government can be conducted. For the Tamsui River watershed, we used the MNDWI and mathematic morphology to extract the water body of two epochs. The difference between the two epochs is shown in Figure 9. The AWEInsh and mathematic morphology were more suitable for the Beigang River to extract water bodies. The difference between the two epochs is shown in Figure 10. The AWEIsh had the best performance in the Zengwen River, including downstream plains and midstream areas of hillsides. The difference between the two epochs is shown by the changes in the river channel ( Figure 11). The Qishan River is located in an upstream area with mostly mountainous terrain and only a few artificial buildings; the NDWI and I and mathematic morphology exhibited the best performance for the Qishan River. The difference between the two epochs is demonstrated by the changes in the river channel ( Figure 12). For the Xiuguluan River, using NDWI and mathematic morphology had the best performance in extracting the water bodies of the two epochs. The difference between the two epochs is shown in Figure 13.