{'fraction_non_alphanumeric': 0.030689866223660052, 'fraction_numerical': 0.01919209582932587, 'mean_word_length': 4.775056803837415, '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}}
Brain MRI Images Segmentation Based on U-Net Architecture

Brain tumors are collections of abnormal tissues within the brain. The regular function of the brain may be affected as it grows within the region of the skull. Brain tumors are critical for improving treatment options and patient survival rates to prevent and treat them. The diagnosis of cancer utilizing manual approaches for numerous magnetic resonance imaging (MRI) images is the most complex and time-consuming task. Brain tumor segmentation must be carried out automatically. A proposed strategy for brain tumor segmentation is developed in this paper. For this purpose, images are segmented based on region-based and edge-based. Brain tumor segmentation 2020 (BraTS2020) dataset is utilized in this study. A comparative analysis of the segmentation of images using the edge-based and region-based approach with U-Net with ResNet50 encoder, architecture is performed. The edge-based segmentation model performed better in all performance metrics compared to the region-based segmentation model and the edge-based model achieved the dice loss score of 0. 008768, IoU score of 0. 7542, f1 score of 0. 9870, the accuracy of 0. 9935, the precision of 0. 9852, recall of 0. 9888, and specificity of 0. 9951.


I. INTRODUCTION
Brain tumors are abnormal brain tissue collections. A very rigid skull protects the brain. In such a confined space, growth might cause issues. Brain tumors are classified as benign or malignant. A benign or malignant tumor may expand the skull tumor. Tumors may be identified by their origin. The majority of brain cancer cells diseases are primary tumors of the brain. The most commonly diagnosed cells in the brain moved from different parts of the body are secondary (metastatic) brain tumors [1]. Magnetic resonance imaging is a widely used tool for diagnosing brain cancers. There are several magnetic resonance sequences, each focusing on a different kind of normal or abnormal tissue [2]. Native T1-weighted (T1), post-contrast T1-weighted (T1ce), T2-weighted (T2), and T2 fluid-attenuated inversion recovery (T2-FLAIR) MR modalities were used in this study. Figure 1 shows all these modalities.

Fig. 1: Four Different Modalities of MRI
Segmenting medical images is the initial step in diagnosing, planning, and investigating brain tumor disease. Currently, tumor segmentation is done manually by a radiologist, which takes a long time. It may take several hours for a single patient to perform the task, and radiologists need to concentrate for a long time.
Gliomas are a form of tumor that needs therapy as soon as it is identified in a patient, hence rapid segmentation is required. Auto-tumor-segmentation is superior to manual tumor-segmentation in speed and accuracy. It will also minimize the period between diagnostic testing and therapy, allowing clinicians to focus on the patient's health and design a treatment plan.
Deep neural networks have recently attracted researchers due to their great performance and accuracy in image segmentation [3]. A CNN can recognize and infer characteristics from images. Many research has utilized CNN to segment brain tumors on MRI images. This research proposes a method to segment brain tumors. Images are segmented using edge-based and region-based methods. The brain tumors are segmented using U-Net with ResNet50 encoders.
This paper presents methods for the segmentation of brain tumors using region-based and edge-based approaches. This paper is divided into various sections. Section I describes the introduction and background of brain tumors. Section II describes the literature review, Section III describes methods and procedures, Section IV shows the experimental results, and Section V describes the conclusion and future work.

II. LITERATURE REVIEW
In 2017, Hao Dong et al. [4] developed a completely automated tumor detection and segmentation system using U-Net architecture. Based on studies utilizing BraTS2015 datasets encompassing both patients with low-grade gliomas (LGG) and high-grade gliomas (HGG), they have proven that their technique can yield both competent and vigorous segmentation. Moreover, the U-Net model may produce comparable results for the total tumor tissue and superior results for the core tumor tissue. The model achieved a dice coefficient score of 0.86, 0.86, 0.65 for complete, core, and enhancing tumors respectively.
In 2017, Chinmayi et al. [5] developed the Bhattacharya coefficient, an unsupervised approach for autonomous brain image segmentation. After preprocessing, an anisotropic diffusion sensor with an 8-connected neighborhood is used to the generated MRI images to eliminate noise. The second stage selects sample points for deep learning training using CNN using the Fast-Bounding Box (FBB) technique. The accuracy and similarity index was evaluated. The accuracy of the model is 98.01%, which is higher when compared to other related models.
In 2019, Pereira et al. [6] was proposed the new convolution neural network technology for the MRI segment of brain tumors. Correction of the deviation field, intensity, and patch normalization were all part of the preprocessing stage. Later in the training phase, the number of unusual LGG classes was artificially raised by rotating the training patch and employing HGG samples, resulting in a higher number of training patches.
In 2020, Hassan Ali Khan et al. [7] used the CNN approach combined with data enhancement and image processing to categorize malignant and non-cancerous MRI brain images. It removes the black borders and instead just takes the brain region using open-source computer vision (CV) canny edge detection. Data were also flipped, rotated, and brightened to increase their number and complexity. The model was tested on a small dataset and obtained 100% accuracy.
In 2020, Xue Feng et al. [8] developed 3D U-Nets for brain tumor segmentation. The model attained median dice scores of 0.870 for enhancing tumor (ET), 0.926 for whole tumor (WT), and 0.911 for tumor core (TC). When designing multi-site and multi-scan MRI acquisitions, researchers used ntensity normalization to reduce variability. They looked at using additional data to cope with the diversity in geographical location and anatomical makeup of brain tumors. They investigated rotating patches and sampling under-represented HGG classes in LGG. Brain tumor segmentation is still understudied in deep learning algorithms. They also compared the deep CNN to a surface architecture with a bigger filter to assess the feasibility of building a deep architecture with a tiny core. Finally, they verified the importance of the activation leaky rectified linear unit (LReLU) function in CNN architecture training.
In 2021, Fabian et al. [9] used neural network nnU-Net in the segmentation task of the BraTS Challenge 2020. Amazing results have been achieved by the basic nnU-Net configuration. Researchers increased the segmentation results of the nnU-Net pipeline by introducing BraTSspecific improvements such as post-processing, regionbased training, a more aggressive data augmentation, and a few minor changes. In 2021, Gunasekara et al. [10] proposed an automated technique for identifying, segmenting, and retrieving precise tumor borders from MRI scans 2021. To categorize axial MRI into meningioma and glioma brain cancers, the researchers built a 93.6% confident tumor bounding box using a rudimentary CNN architecture with restricted layers. Researchers employed the Chan and Vese unsupervised adaptive threshold detection technique to obtain accurate tumor boundaries. These metrics were computed by comparing the border area segmented to the total system performance. The suggested architecture has a dice Score of 0.92.

III. METHODS AND PROCEDURES
In this paper, we proposed edge-based segmentation and region-based segmentation using U-Net with the ResNet50 encoder as a backbone to increase the accuracy of MRI image segmentation based on human brain tumor disease. The workflow diagram of the proposed method is depicted in Fig. 2. The proposed method comprises data preprocessing, edge and region detection, and segmentation. Initially, the pre-processing of the given MRI image is followed by a brain edge or region detection and then the segmentation that lucidly shows the tumor area.

A. Dataset
This section discusses publicly accessible datasets used in this research. For fully automated brain lesion detection and segmentation, the BraTS2020 dataset is proposed. BraTS has always been focused on testing advanced methods for segmenting MRI-based brain tumors. To separate brain tumors like gliomas, inherently different forms, appearances, and histologies, BraTS2020 relies on multi-institutional MRI imagers. BraTS'20 also combines integral radiomic properties analysis with machine learning methods to demonstrate the clinical value of this segmentation task by predicting the patient's general survival and distinguishing pseudo development from true tumor recurrence. Finally, BraTS'20 is trying to assess tumor segmentation algorithmic uncertainty.
Any BraTS multimodal scanning in the nifty form describing the T1, T1ce, T2, and T2-FLAIR is provided and has been acquired from a range of clinical protocols and organizations involved in scanning.

B. U-Net Architecture
In 2015, Ronneberger et al. [11] projected the U-Net architecture, which was among the first convoluted networks created exclusively for biological-image interpretation. The model has a shape similar to the English letter "U." The encoder is also known as the contracting path, is made up of the basic convolutional process, whereas the decoder, also known as the expansive path, is built up of transposed 2D convolutional layers, as seen Fig. 3.
Each operation in the contracting path contains 2 layers of convolution, with the number of channels increasing from 1 to 64 as the image depth is enhanced via the convolution process. The red color arrow pointing down represents the max-pooling process, which reduces the image size by half (the size reduction from 572 × 572 → 568 × 568 is due to padding difficulties, but padding = "same" is used here).
The image was resized to its original size in the expansive path. Transposed convolution is a technique for increasing the size of images by up-sampling them. It basically pads the original image before doing a convolution process. The image is upsized from 28×28×1024 to 56×56 ×512 after the transposed convolution. The purpose of this process is to aggregate the information from the previous layers to obtain a more exact forecast, and two additional convolution layers are added as well. This technique is recurrent three times more, as previously. The final stage is to reform the image to meet our prediction criteria. The former layer is a convolution layer with one 1×1 filter. The dense layer, which is particularly prevalent in CNNs for classification tasks, is not present in the entire network. The rest of the training for neural networks is the same.
The expansion path in a conventional U-Net is almost symmetrical to the contracting path. Instead of employing a standard set of convolution layers, we propose adopting a novel transfer learning architecture as an encoder in the contracting path in this work. The decoder module works in the same way as the original U-Net. To reliably separate the brain tumor in MR images, we suggest various U-Net semantic segmentation topologies. The U-Net structure is used in these five networks. An encoder (down-sampling path) extracts image context maps, and a decoder (upsampling path) extends the collected mappings for a pixel segmentation mask to be generated in each network. In addition, every network features skipping connections that allow the transmission of information via a precise segmentation map from the encoding path to the corresponding levels.

C. Data Preprocessing
Center cropping is applied to crop the images from the center. The MRI intensity value relies on the imaging system and scanner used, standard scaler normalization is employed to remove the distortion from the image. Sample 's standard score is calculated as follows: Where is the 'standard deviation', and is the 'mean' of the training sample. Standard scaler's concept is that it will transform the data into distribution with a standard deviation of 1 and a mean of 0. This is done feature-by-feature in the case of multivariate data.

D. Edge Based Segmentation
To determine the borders of the wanted object within the image when accessing the image processing, the main purpose for the edge sensing technique can be defined. The edge algorithms are done by assessing the sudden increase or fall in every intensity of the pixels and only visualizing the sudden changes in the pixels. This pixel difference is crossed by a suitable convolution mask, and the resulting edges of the image are described [12].
The approach for the detection of the canny edge is used in this study. Canny edge detection is one of the most impactful and frequently used image processing devices for edge detection. In 1986, John F. Canny developed the canny edge detection algorithm [13]. This algorithm contains the basic steps such as reducing noise using gaussian filters, calculation of gradients along the vertical and horizontal axes, non-maximal falsified edge removal, double seclusion thresholds for weak and strong borders, hysteresis edge tracking.
In canny edge detection, noise reduction with a gaussian filter is extremely important. It uses a gaussian filter, as these noises can be seen as borders, to remove noise from the image. After all, the edge detector changes suddenly in intensity. When the image is flattened, the Ix and Iy derivatives are measured concerning the -axis and y-axis. It can be carried out with the image convolution of the Sobel-Feldman kernel. The dimensions of the gradient and the angle of this kernel continue the process. Non-maximum removal of falsified edges aim is to reduce the duplicate pixels fused around the edges so they are uniform. If the existing pixel is greater than the magnitude of its neighbors, the magnitude of the pixel intensity is set to zero. Two specified threshold values are compared to gradient sizes, the first is below the second. The gradients below the lower threshold are removed, the gradients above the high threshold high, and the pixels on the last border map are shown. All the other gradients are marked as weak gradients and pixels corresponding to them are taken into account in the following steps.
Due to its connection to a strong edge pixel of a weak edge pixel induced by real edges, the weak pixel will be marked as an edge and is only used in the final edge map if it is the same as some pixel with a high gradient. We will develop and implement an algorithm that only once takes account of all the coordinates of the gradient map. The final edge map then allows deciding which pixels are included. The final edge map then allows deciding which pixels are included. Figure 4 shows the image after edge detection.

E. Region-based Segmentation
This approach involves dividing an image into regions equivalent to a variety of constraints. The region-based segmentation technique includes an algorithm that divides an image into different components with related pixels. For segmentation purposes, this technique looks for small or large pieces in an input image. We are using the "watershed transformation" to try a region-based method. Firstly, a map with the image's "Sobel gradient" can be found. The background and image markers are also available based on the extreme part of the histogram of the gray value. Finally, to fill the elevation map regions starting with the above markers we use a "watershed transformation". This last procedure works better and the images can be individually segmented and labeled. Figure 5 shows the image after region detection.

F. Training and Implementation
The BraTS dataset includes MRI images and the associated segmentation results for training and model testing. Neuroradiologists who are clinically qualified correct images marked output or ground truth. The train data and validation data folders are in the BraTS dataset. Each subfolder contains 5 sophisticated pictures of five different models, such as T1, T1ce, T2, T2-FLAIR, and Seg. The data folder contains 369 subfolders. In the training dataset, a total of 1845 images. A data validation folder contains 125 subfolders and four images in four different modes such as T1, T1ce, T2, and T2-FLAIR in each subfolder. In the validation data folder, there are a total of 500 images.
After evaluating the data, the images are pre-processed by standardizing the intensity value and cropping them. Applied edge-based or region-based algorithms before augmenting the dataset. MRI records are split into three categories: train set, test set, and validation set. 60% of the images are used as the train set, 20% are used as the test set, and 20% are used as the validation set. The training images are data augmented, which aids generalization and enhances accuracy. The albumentation library uses techniques of enhancement, such as grid distortion, random brightness comparison, elastic transformation, optical distortion to extend the input picture and provide further information for the model to be learned. Firstly, before we begin training our model, we need to establish the learning process. An optimizer, a loss function, and some metrics such as F1 score and IoU score have to be specified, optionally. In this study, the segmentation was based on the U-Net with ResNet50 encoder architecture.
G. Performance Metrics 1) IoU Score: "The intersection of the ground truth with the prediction segmentation by the place of union between the ground truth (actual data) and the prediction segmentation is divided between the ground truth" It is a useful metric to determine the intersection of two masks or bounding boxes [14].
2) F1 Score: "The harmonic mean of recall and precision" is used to get the f1 score [15]. F1 score is also known as the dice score.
An f1 score can have the highest possible value of 1.0, which indicates perfect recall and precision, and a lowest possible value of 0 if either recall or precision is zero.

3) Dice Loss: Prevalent loss function is based on the dice coefficient for image segmentation tasks. Dice loss is calculated by subtracting the dice coefficient from 1.
= 1 − (4) "By multiplying the area of intersection by the total number of pixels in both images, the dice coefficient is computed" [16]. The Dice coefficient is calculated as follows: |A∩B| signifies the elements that are common in sets A and B, and |A| denotes the set A's number of elements. The same holds true for set B.
When measuring a dice coefficient on predicted segmentation masks, we may estimate |A ∩ B| as the element-wise multiplication of the prediction and target masks and then sum the resultant matrix. 4)Accuracy: Accuracy is the ratio of correctly predicted observations to the total observations. = ( + ) Where TP is True Positive, FP is False Positive, TN is a True Negative, and FN is False Negative

IV. RESULTS & DISCUSSIONS
Segmentation capabilities for the accuracy, dice loss, IoU score, F1 score, precision, recall, and specificity are analyzed and implemented in the proposed architectures. The network is trained in a batch size of 16 for 200 epochs. In this study comparative analysis of region-based segmentation and edge-based segmentation using U-Net with ResNet50 encoder, architecture is performed.
The performance metrics of architectures are presented in Table I. In the edge-based segmentation model, the U-Net with ResNet-50 encoder architecture achieved the dice loss score of 0.008768, IoU score of 0.7542, f1 score of 0.9870, the accuracy of 0.9935, the precision of 0.9852, recall of 0. 9888, and specificity of 0.9951. Figure 6 shows the learning curve and Fig. 8 shows the prediction of the region-based segmentation model.
The U-Net with ResNet-50 encoder architecture achieved the dice loss score of 0.009538, IoU score of 0.7375, f1 score of 0.9846, the accuracy of 0.9923, precision of 0.9807, recall of 0.9886, and specificity of 0.9935 in the region-based segmentation model. Figure 7 shows the learning curve and Fig. 9 shows the prediction of the regionbased segmentation model. When the results of edge-based and regional segmentation architecture are compared, edgebased segmentation is better in all performance metrics.
For training a model, the training parameters are the most relevant factor. It is therefore essential to use the same dataset and set all training parameters in the same manner. It can be used for image segmentation after the network is trained. The segment images using the trained model take only a few seconds. On the other hand, it may take hours to manually segment tumors by clinicians. The image segmentation procedures suggested helps doctors diagnose a brain tumor quickly and accurately so that many people can perhaps save their lives. Table II illustrates the comparison of the results of the proposed edge-based segmentation using U-Net with ResNet50 architecture with some state-of-the-art methods. In its comparison with the proposed model with the results from the previous researches, shows that the proposed segmentation model performed well with the highest accuracy of 99.35% and a dice score of 98.70%.
This study proposed an automatic method to segment the brain tumor using a 2D network. So the architecture lacks a significant degree of semantics and local features between the pieces. This is the limitation of this study.    [17] 0.9203 -Gunasekara et al. [10] 0.92 0.9457 Fabian et al. [9] 0.8895 -Chinmayi et al. [

V. CONCLUSIONS
Various approaches for brain tumors segment were presented in this paper. Firstly, using the technique of edgebased segmentation, and other using region-based segmentation. Here, proposed a U-Net with ResNet50 encoder architecture for efficiently segmenting brain tumors. In this study comparative analysis of region-based segmentation and edge-based segmentation using U-Net with ResNet50 encoder, architecture is performed. The model is evaluated based on dice loss, IoU score, f1 score, precision, recall, accuracy, and specificity. The edge-based segmentation achieved the highest scores in all performance metrics with the dice loss score of 0. 008768, IoU score of 0. 7542, f1 score of 0. 9870, the accuracy of 0. 9935, the precision of 0. 9852, recall of 0. 9888, and specificity of 0. 9951. The edge-based segmentation played a key role in the treatment of brain tumors, according to the test findings. The proposed model foresees the segmentation of brain injuries and assists in the precise segmentation of the lesions.