{'fraction_non_alphanumeric': 0.029128518141742964, 'fraction_numerical': 0.008307900983384199, 'mean_word_length': 4.707567253725566, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
On Mathews Correlation Coefficient and Improved Distance Map Loss for Automatic Glacier Calving Front Segmentation in SAR Imagery

The vast majority of the outlet glaciers and ice streams of the polar ice sheets end in the ocean. Ice mass loss via calving of the glaciers into the ocean has increased over the last few decades. Information on the temporal variability of the calving front position provides fundamental information on the state of the glacier and ice stream, which can be exploited as calibration and validation data to enhance ice dynamics modeling. To identify the calving front position automatically, deep neural network-based semantic segmentation pipelines can be used to delineate the acquired SAR imagery. However, the extreme class imbalance is highly challenging for the accurate calving front segmentation in these images. Therefore, we propose the use of the Mathews correlation coefficient (MCC) as an early stopping criterion because of its symmetrical properties and its invariance towards class imbalance. Moreover, we propose an improvement to the distance map-based binary cross-entropy (BCE) loss function. The distance map adds context to the loss function about the important regions for segmentation and helps accounting for the imbalanced data. Using Mathews correlation coefficient as early stopping demonstrates an average 15% dice coefficient improvement compared to the commonly used BCE. The modified distance map loss further improves the segmentation performance by another 2%. These results are encouraging as they support the effectiveness of the proposed methods for segmentation problems suffering from extreme class imbalances.


I. INTRODUCTION
The mass loss of the Polar ice sheets and other calving glaciers has accelerated in the last two decades. This is one of the main causes of global sea level rise. Currently, the sea level contribution from thermal expansion is exceeded by the contribution from ice sheets, glaciers, and ice caps [1]. The retreat of the glacier fronts can produce a re-enforcing effect of ice loss. For example, the retreat from the pinning points can reduce the lateral buttressing forces, which further destabilize the glaciers' ice discharge into the ocean [2]. A significant frontal retreat can further cause a retreat of the grounding zone leading to further destabilization of the glacier flow [3]. This makes the calving front, the region where the glacial ice breaks * AmirAbbas Davari and Saahil Islam contributed equally to this work. A. Davari off into the ocean. Hence, the calving front position (CFP) is an important variable for monitoring, but also ice dynamic modeling.
The detection of the calving front locations is commonly carried out using optical imagery or Synthetic Aperture Radar (SAR) imagery. Cloud covers and polar nights affect the optical imagery and the data coverage is strongly curbed. On the other hand, SAR acquisitions are unaffected by such situations and can be carried out all year round, making SAR imagery more advantageous for monitoring purposes in polar regions. The common approach to detect CFPs has been visual analysis and manual delineation on the obtained SAR images. However, manual digitization is tedious, subjective, expensive, and timeconsuming. Moreover, sea ice and calved-off icebergs in the oceans make it often difficult to reliably differentiate between ice mass and these chunks of floating ice, making manual delineation subjective. This leads to a lack of temporally updated data on the position of the calving front, which is considered an essential climate variable (ECV). Automatic detection of CFPs would close this monitoring gap. In the past, various algorithms of automatic and semi-automatic detection of the calving front positions had been proposed. Edge detection algorithms such as Roberts edge extractor has been applied to ERS-1 SAR images by Sohn et al. [4]. Seale et al. [5] have exploited Sobel filter and brightness profiling to detect the CFPs on daily MODIS images. A detailed overview of various automatic and semi-automatic approaches on this application is provided by Baumhoer et al. [6].
Deep learning-based methods such as Convolutional Neural Networks (CNNs) [7] are a better alternative to the traditional automatic delineation of CFPs. Over the past two decades, CNNs have been seen to outperform the above-mentioned manually designed filter-based methods and many such traditional computer vision techniques in the field of image processing [8]. The CNN architecture (the type and number of layers and their order) is chosen depending on the application and the training data. The parameters in a CNN are fine-tuned based on optimizing a predefined objective function, also referred to as cost function or loss function.
Deep convolutional networks can be used on SAR images to automatically classify the image pixels, belonging to semantically different regions, into distinct classes. Such a task is referred to as semantic segmentation. Architectures such as SegNet [9] and U-Net [10] are commonly used for semantic segmentation applications [7]. The use of the U-Net architecture for SAR image segmentation was first exploited by Mohajerani et al. [11] on Landsat-5, 7, and 8 images to automatically detect calving fronts. Zhang et al. [12] have used U-Net on higher resolution TerraSAR-X images of Jakobshavn Isbrae glaciers to separate the whole ice mélange regions from non-ice mélange regions, which are subsequently post-processed to manually delineate the calving fronts.
Despite being powerful learning tools, the high number of parameters in Deep Neural Networks (DNNs) comes with the risk of over-fitting to the training data [13], i. e., it "memorizes" the non-predictive features of the training data instead of "learning" its underlying distribution In this paper, one contribution focuses on proper exploitation of early stopping to prevent the network from over-fitting [14].
Early stopping suggests stopping training based on the error on independent validation data to maintain high performance on new unseen data from the same distribution. Since the training gets terminated based on the error on the validation data, it is crucial to have the right performance metric as a stopping criterion. The traditional method of early stopping comprises monitoring the loss [15]. However, the significance of the performance metric increases in cases of class-imbalanced data [16]. An imbalanced dataset comprises classes with an unequal number of class elements. The majority of performance metrics are challenged in the presence of severely imbalanced data. For example, accuracy is not an appropriate metric in applications with class-imbalance as incorrect classifications of the minority class could be overlooked. On the other hand, other metrics such as f1-score greatly diminishes the effect of class imbalance. Mathews Correlation Coefficient (MCC) is theoretically argued to have a higher tolerance over class imbalance than f1-score and confusion entropy [17], [18] and was for example used to compare between a vast range of classifiers for evaluation of models on micro-array gene expression and genotyping data [19]. In this paper, we are suggesting (a) the use of early stopping to prevent over-fitting and (b) using MCC instead of the classical BCE loss as stopping criterion.
While early stopping handles over-fitting with the right performance metric, it is also crucial to objectively handle the learning of the network on the imbalanced dataset. The imbalanced dataset introduces a bias towards the majority class during the training of the network while the minority class is the point of interest in many real-world problems. Common solutions are for example data re-sampling [20], cost-sensitive learning, one class learning, or ensemble learning methods [21]. While these methods could be effective, they do not guarantee to be so in all kinds of tasks. For example, over-sampling undergoes a risk of early over-fitting because the network uses many samples more than once while under-sampling reduces the size of the training data. Artificially balancing the class distributions was not very successful in some tasks [22] and many ensemble-based methods are resource-demanding and time-consuming [21].
Another way of cost-sensitive learning is to weigh the minority class higher to punish miss-classification. In imbalanced segmentation tasks, the loss function can also be trained to penalize more the contour of the segmentation masks than the regions. Kervadec et al. [23] used such a boundary-based loss function for medical image segmentation. They argued that region integrals of the segmentation masks highly vary over the classes and instead trained on the space of contours. Another distance-based loss approach was stated to segment knee bones in 3d MRI [24]. However, they employed the idea of a distance map-based loss because most errors in segmentation are found to be at the edges of the segmented masks. A distance map-based loss was also used by Adhikari et al. [25] to detect forest trails in optical images of forests, which cover only small regions in the images. Therefore, the trails were weighted higher in the loss function while the other regions were weighted less based on the distance to the forest trails.
In this paper, we show that the use of MCC as an early stopping criterion is superior to a binary cross-entropy (BCE) monitored network. The performance of the network is further enhanced by an improved distance map-based BCE loss and is compared with (a) the traditional BCE loss and (b) a weighted BCE loss. The rest of this paper is organized as follows: Section II reviews the tools that have been used in our contributions, i. e., Mathews correlation coefficient, and the distance map loss. Section III describes our proposed pipeline and explains the main contributions of this paper in detail. Next, the dataset description, experimental setup, and the quantitative and qualitative results are presented and discussed in Section IV. Finally, Section V concludes the paper.

A. Mathews Correlation Coefficient
Binary cross-entropy is a popular loss function in binary classification scenarios. A good loss is usually supposed not to produce very small or extremely large gradients, which is one of the desirable properties of the BCE loss [26]. We could choose to use the validation BCE loss also as an early stopping criterion. However, BCE loss is very fragile in the presence of class-imbalance [27]. Hence, it becomes an unfavorable early stopping criterion for class-imbalanced segmentation.
On the other hand, MCC represents true positives (TP), false negatives (FN), false positives (FP) and true negatives (TN) in a balanced manner [28]. It is balanced in the sense that the rate of positive class predictions and negative class predictions are given equal importance. MCC is defined as: .
(1) It lies in the range [−1, 1] with 1 representing the perfect prediction, −1 denoting wrong, and 0 suggesting random prediction. MCC takes positives and negatives equally into account and provides very little "discrimination" to random acts [17].

B. Distance Map Loss
While BCE is the most commonly used loss function in most deep learning-based methods, it is not favorable for classimbalance problems. A common approach to tackle the classimbalance with BCE loss is to weigh each class with its inverse class frequency. However, it does not always guarantee to produce better performance [22]. Moreover, minority classes with higher weights can lead to noisy gradients [25]. On the other hand, a distance map-based approach adds context to the loss functions based on the regions of importance in the segmentation task. Distance maps, also known as distance fields or distance transforms, are derived representations of an image based on a distance metric. In computer graphics, distance maps are often used for volume rendering to generate offset surfaces or a blending between surface models [29].
A distance map-based loss trains the network by penalizing the predictions with respect to its distance from the object of interest in the image. A distance map-based loss is also beneficial for class imbalance. By forcing the network to give more attention to the regions of interest (minority class), it counters the bias of the network's training towards the majority class. The distance map loss works on the idea of weighting far away pixels (from the semantic line) higher than the ones in its proximity [25]. The loss is formulated as: with g being the ground truth map and p the prediction at pixel location i, j. The distance map is denoted as d, with d max being the maximum distance, and M, N represent the spatial dimensions of the maps.

III. METHODOLOGY
A. Processing Pipeline Figure 1 outlines our proposed segmentation workflow. We perform the segmentation of calving fronts images using a U-Net architecture. The SAR images are used as input to the network, which learns either to predict the zones of ice mass regions or the calving front lines, depending on the ground truth data presented to the model at training time. In the rest of this paper, we refer to the ice/non-ice regions as zones and calving front locations as front lines for convenience. In the variant that the network is trained to predict the ice zones, the predictions are post-processed to extract the boundaries and in this way obtain the front lines.
The images are first pre-processed to remove noise and then patches of a predefined size were extracted from both the images and their corresponding ground truth before they are fed to the network. Before extracting the patches, the images are padded with zeros to the next larger image size that is a multiple of the patch size. The predicted masks on the patches are later stitched together to reconstruct the original size image, and the padding is discarded.

B. MCC as the Early Stopping Metric
The data is split into three subsets, namely training, validation, and test set. We use early stopping to stop the training before it overfits. However, the validation error is usually very noisy. Hence, to ensure that the training terminates where the validation performance is optimum, we pre-define a patience number. This is the number of epochs the early stopper waits to check for improvement on the validation error before terminating the training when no improvement is noticed. The common practice is to monitor the BCE loss on the validation set. However, due to the severe class-imbalance, we propose the use of the Mathews correlation coefficient (MCC) as an early stopping metric as it is theoretically more robust towards class-imbalance.

C. Modified Distance Map and Distance Map BCE Loss
We formulate the distance map in a generalized form to be used in different loss functions. The computed distance map weighs the line locations higher while the regions around the proximity of the front lines are weighed less based on the distance to the lines. As we move progressively away from the front line locations, the weights keep reducing until they become 0. In other words, true line locations are given high importance and the proximity adds relaxation to the network. The points beyond which these weights become zero are considered to be the background (majority class). In contrast to the distance map-based approach by Adhikari et al. [25], cf. Eq. (2), we weigh the background differently depending on the class imbalance. In particular, we calculate the distance map from the ground truth masks as follows: We first thicken the ground truth lines by morphological dilation (δ w ) [30]. Then, we use the Euclidean distance transform (EDT), divided by a constant factor of R. The strength of relaxation is determined by R, i. e., how smoothly the weights fall off from the front lines to the background. The morphological dilation of the ground truth images thickens the front lines based on the structuring element used. We use a rectangular structuring element with a size of (w, w), where w determines the amount of thickening of the lines. It is further passed through a sigmoid function σ to obtain values in the range of [0, 1]: where y denotes the ground truth. Finally, the distance map d is obtained by: where k is a constant in the range of (0, 1] determining the weight given to the background, with k = 1 signifying utmost importance. Since we deal with high class imbalance, a high weight is not desirable. However, it is a hyper-parameter that depends on the dataset and its class imbalance ratio, and needs to be tuned. Various distance maps are depicted with different w, R, and k in Fig. 2. Finally, the distance map computed on the ground truth is used in the BCE loss to create the distance map BCE loss. The BCE loss (J BCE ) is given by: whereŷ is the prediction, y is the ground truth, and N is the batch size during training. Incorporating the distance map into the BCE loss (J DBCE ) results in:

A. Dataset
We perform our experiments on SAR images obtained from sites of the Antarctic Peninsula (AP) and Greenland, depicted in Fig. 3. AP has been strongly affected by changing climatic conditions [31]. The Dinsmoor-Bombardier-Edgworth (DBE) and the Sjögren-Inlet (SI) glacier had undergone a strong frontal retreat over the years [32], [33]. Jakobshavn Isbrae is one of the largest tidewater glaciers in Greenland and went through a drastic retreat over the last decades [34].
The SAR images of the AP were calibrated and multi-looked to remove speckle noise. Furthermore, the images were geocoded and ortho-rectified by means of the enhanced ASTER digital elevation model of the AP [35]. The ground truth of the front lines is taken from Seehaus et al. [32], [33]. The images vary on the basis of their spatial resolution. High spatial resolution images cover an area of 5 m × 5 m per pixel and range until the lowest resolution of 50 m × 50 m per pixel. Out of 244 available SAR images at the AP, randomly 50 images were kept for testing, another 50 were used for validation, and the rest served for training the model. We increase the AP training dataset three times by augmenting with horizontally flipped image versions as well as by 90°rotated versions. The Jakobshavn Isbrae glacier calving front locations were provided by Zhang et al et al. [12]. The SAR images of Jakobshavn Isbrae were preprocessed with a median filter to remove speckle noise. All the images have a constant spatial resolution of 6 m × 6 m per pixel. We use 25 random images for validation, 25 for testing, and the remaining 119 images as the training set. The training data is augmented by adding horizontally flipped image versions.
The SAR images of AP also vary in size. The smallest of the images has dimensions of 377 × 458, and the largest one contains 3770 × 4581 pixels. Conversely, Jakobshavn Isbrae images are all approximately 1600 × 3500 pixels in size. For both datasets, two ground truth images are available: The calving front lines, and ice/non-ice zones. Figure 4 depicts a sample SAR image in our dataset, along with its corresponding ice/non-ice zones ground truth and its glacier calving front ground truth images. The zones have a training class-imbalance of 1:3 in both datasets. The front line ground truth is severely imbalanced with a ratio of 1:2097 in AP training data and a ratio of 1:1124 in Jakobshavn Isbrae training data.
B. Experimental Setup 1) Architecture and Parameters: We followed Zhang et al. [12] as our baseline architecture. Both the convolution and transposed convolution layers have kernel sizes of (5, 5). We use leaky ReLUs as the activation functions with a negative slope of α = 0.1, and the pooling layers have a pooling size of (2, 2). For regularization, batch normalization layers have been exploited after every convolutional layer. Furthermore, we use Adam as the optimizer [36] and a cyclic learning rate for optimization, which is beneficial to the learning of the network [37]. Due to the constant changes in the network's performance by the cyclic training during training, we set a rather high patience value (30 epochs) for early stopping. Note that we also tried various other patience values for a subset of the experiments and the same behavior has been observed. Hence, we decided to use 30 for all experiments so that we give BCE early stopping criterion enough time to bring the validation loss down, too. We use a patch size of 256 × 256 pixels for patch extraction. The prediction of zones differs from the prediction of lines in the context of class-imbalance. Hence, we use slightly different parameters for these two different ground truths, which are explained in the following experiments.

2) Experiment 1: Early Stopping Criterion: MCC vs. BCE:
To demonstrate the importance of the metric used as the early stopping criterion, we perform the segmentation on (a) the zones and (b) on the lines, and compare the performance of BCE and MCC as the early stopping criteria. For segmenting zones, a batch size of 20 is used. The maximum learning rate of 1e−2 and a minimum of 1e−7 is used in the cyclic learning rate with a step size of 5× epochs. To extract the calving front lines from the predicted zones, we post-process our predictions as follows: First, the false alarms are removed by extracting the largest connected component in the image. Then, we use canny edge detection [38] to delineate the calving front lines from the rectified zones.
In the second variant, where we train our model using the calving front lines directly, the front lines are one-pixel wide. This contributes to the major reason for the extreme class-imbalance. To facilitate the network's training on such a highly imbalanced dataset, the lines were thickened using morphological dilation with a rectangular structuring element of size 5 × 5 pixels. This reduces the class-imbalance of AP Dataset lines to 1 : 420 and of Jakobshavn Isbrae to 1 : 225. We use a batch size of 15 for the front lines. The cyclic learning rates parameters for the lines are 1e−4 and 1e−8 as maximum and minimum, respectively.
3) Experiment 2: Improved Distance Map BCE Loss vs. BCE loss: After proving the fact that MCC as an early stopping criterion accomplishes better results, we perform our second experiment using MCC as an early stopping criterion. In the second experiment, we compare the performance of the improved distance map BCE loss (i.e., with optimum k) with the conventional BCE loss, inverse class-frequency weighted BCE, and the conventional distance map BCE loss (i.e., with k = 1). This experiment is designed only to tackle high classimbalance. Hence, the models are trained only using the front line ground truth images of both the datasets. We use the same parameters for predicting front line masks as in our first experiment. We search for the best parameters for the modified distance map formulation using grid search and thereby, select w = 3 and R = 1 for both datasets. The best value of k was found to be 0.1 for AP and 0.25 for Jakobshavn Isbrae.

C. Evaluation
We use the performance metrics, that are commonly used for segmentation problems [39], [7], i. e., Intersection Over Union (IOU) and Dice coefficient, to evaluate our experiments. We also report the MCC. IOU is the area of overlap between the predicted masks p and the ground truth masks g divided by the area of union between the predicted masks and the ground truth masks. The Dice coefficient is twice the area of overlap divided by the total number of pixels from predictions and ground truth.
These performance metrics solely represent how well the predictions overlap with the ground truth masks. This makes it hard to evaluate the calving front lines because even if they are very close to the ground truth locations, they will be considered as a miss by these metrics. Therefore, to make these metrics more comprehensible, we further dilate the predictions and ground truth masks. The dilated pixels around the ground truth are considered as the relaxation or tolerance. Since our datasets also come with spatial resolution, we calculate the tolerance in meters. The spatial resolution s denotes the actual distance one pixel covers on earth. Therefore, the tolerance t is calculated as t = s × p/2. The tolerance scheme is depicted in Fig. 5. The metrics are reported in our tables along with the tolerance (in meters) for the predicted calving front lines. Table I shows the results when using BCE and MCC as an early stopping criterion. Monitoring MCC clearly outperforms BCE in all cases. Prediction of zones in Jakobshavn Isbrae does not show much improvement as BCE as early stopping   Table I also illustrates that monitoring MCC shows improvement not only when dealing with high class-imbalance, but also is quite reliable for less imbalanced datasets (AP and Jakobshavn Isbrae zones). The fact that the BCE-monitored network is not trained enough can be clearly observed in the qualitative results that are depicted in Fig. 6.
The MCC-monitored network performs significantly better for both zones and lines. Apart from the fact that the calving front lines generated from the MCC monitored network are more accurate, the predictions also seem to have fewer numbers of false positives (incorrect white lines on the black regions). The results of BCE Loss and improved distance map BCE (a) (b) (c) Fig. 6: Comparing the segmentation results using BCE and MCC as the early stopping criterion on AP glaciers: (a) ground truth, (b) segmentation maps predicted using BCE as the early stopping criterion, (c) segmentation maps predicted using MCC as the early stopping criterion.
Loss are shown in Table II. The improved distance map BCE loss is also compared with the distance map using (k = 1).
It is interesting to notice that the distance map BCE loss with k = 1 did not improve the performance of BCE loss in our task of glacier front line segmentation. However, it does show slight improvement with low tolerance (65 m) for the AP glaciers. In contrast, the optimum k helps to deal with the class-imbalance better. The qualitative results of the predicted lines on Jakobshavn Isbrae regions are depicted in Fig. 7. In this figure, the green color represents ground truth, the red color shows the incorrect prediction, and the yellow color depicts the correct predictions, i. e., the overlap between the prediction and the ground truth. The line predictions of Jakobshavn Isbrae glaciers in both losses are disconnected. However, the distance map loss manages to identify more regions of the calving fronts. BCE loss also incorrectly predicts severe outliers (false positives) that are far away from the real locations as depicted in Fig. 7. Such false positives are less numerous in the case of the distance map BCE predictions. Referring to Fig. 8, which depicts the front line predictions of the AP glaciers, we see that the BCE loss predicts several images quite inaccurately. These images are well handled by the distance map loss. When working on the problem of automatic detection of CFPs in the SAR images, the available ground truth data for the training could be the ice zones or the calving front lines. The semantic segmentation of zones on the SAR images needs post-processing to find the calving front locations. Unlike semantically segmenting the zones, a direct semantic segmentation of the calving front locations is a harder problem due to the more severe class-imbalance. Figure 9 qualitatively compares the segmented front lines using the two approaches for the AP glaciers dataset: one approach predicts the front  lines directly and the other post-processes the predicted zones. Direct predictions of calving front lines bring minor disjoints in the predictions, whereas the post-processed zone predictions are continuous. However, the result of the post-processed zone is not entirely the glacier calving front lines. It shows the boundary between ice zones and non-ice zones, which may contain some bedrock boundaries as well. This is also observable on the post-processed predictions for the Jakobshavn glacier in Fig. 10. Moreover, some regions are better predicted by direct front line predictions.

V. CONCLUSION
This paper proposes methods to improve deep learningbased semantic segmentation of the glacier calving fronts. The detection of calving fronts is challenged by its severe class inequality. We have tackled the class-imbalance problem by two approaches. First, the use of Mathews Correlation Coefficient as an early stopping criteria showed a great performance gain. Then, to help the binary cross-entropy loss function to handle the imbalanced data, we incorporated a novel distance map loss. The distance map can be used in conjunction with any other loss function. The MCC-monitored network outperforms the BCE-monitored network by about 15 % dice coefficient and IOU. Using the modified distance map BCE loss results in a further improvement of approximately 2 % dice coefficient.
Finally, two approaches of predicting front lines were compared, i. e., either to directly predict the front lines or to predict ice zones and then post-process the areas to delineate the calving fronts. The presented results in this work are encouraging and we believe that other image segmentation applications with severe-class-imbalance can benefit from the proposed approaches in this work.