1 Introduction

Brain tumor segmentation from brain MRI is critical work in medical image processing. Image segmentation is a challenging operation that involves dividing a digital image into various sections The purpose of image segmentation is to ease the analysis process and determine the position of objects and boundaries in images [1, 2]. Early recognition and treatment of brain tumors are one of the most critical factors in the recovery process and immensely increase patient survival rate [3].

MRI images are more acceptable among doctors due to their sensitivity in contrast and the possibility of revealing very small, non-invasive lesions. Without causing radiation exposure to other regions of the brain and causing damage to the patient's skull artifacts, MR imaging is helpful in the identification and treatment of brain cancers [4]. Therefore, there is a demand for an effective approach to segmenting medical images that have several favored characteristics, such as minimal interaction with the user, precise outcomes, rapid calculation, and reliable segmentation outcomes [5].

The segmentation method is based on dividing the processed image according to intensity variation, such as edges and corners. The second method is based on dividing an image into sections based on a set of specified criteria that are similar. As a result, numerous segmentation techniques can be widely applied, including histogram-based techniques, edge-based techniques, artificial neural network-based segmentation methods, physical model-based approaches, techniques for dividing, expanding, and merging areas, as well as clustering techniques such as Fuzzy c-means clustering, K-means clustering, Partition Clustering, and Mean Shift [6].

A clustering method determines which pixels in an image integrate the best. There are two clustering methods: either by partitioning or by grouping pixels. Partitioning starts with the entire image and splits it into increasingly smaller clusters. In contrast, the grouping type starts by identifying each item as a separate cluster and then merging the single clusters to form bigger ones [7]. Fuzzy c-means is an important and popular unsupervised partitioning algorithm that is used in this study.

Morphology is one of the methods of image analysis, the output of this method describes the contents of the image. Morphology is based on a set of mathematical tools that extract a specific feature from the image furthermore removing unnecessary details and is therefore widely used in histology [8]. This method displays the edges of elements more prominently than other points and its purpose is to change or correct the elements inside a binary image. This operation is usually performed one step before the final processing operation. The final operation means the operation in which information is extracted from the image. For example, the perimeter or area of the image components is calculated. The mathematical morphological approach is the most effective in extracting tumor areas more precisely in the shortest amount of time [9]. A morphological reconstruction is proposed in order to improve the accuracy and reduce the computation time.

The proposed method utilizes image segmentation techniques based on clustering to identify the brain tumor and compute the tumor region. We introduce a new method for segmenting abnormal MRI images, named FCM + MR + AC. In the pre-processing stage, it improves the contrast of the images using histogram matching, and after removing the noise with the median filter, it sharpens the image with unsharp masking. In the next step, it uses the Fuzzy c-means algorithm to segment the brain image. After the clustering stage, in the post-processing stage, it extracts the tumor automatically by combining morphological reconstruction with the active contour. This integrated approach leverages the advantages of both techniques to achieve accurate boundary detection, precise measurements, noise reduction, and time efficiency. It gives an accurate result compared to the Fuzzy c-means algorithm. The original Fuzzy c-means algorithm works well for images without noise. By removing noise from input data in pre-processing, it can improve FCM convergence and create more accurate clusters. As a result, our method gains from combining these algorithms to lower the number of iterations, which influences execution time and provides an accurate result in tumor detection.

The remainder of the paper is organized as follows: Section 2 discusses the related work, Section 3 presents the proposed technique, Section 4 presents experimental research, Section 5 provides the comparative analysis, while Section 6 includes the conclusion and future work.

2 Related work

This section contains relevant research on brain tumor detection using MRI of the brain as well as analysis of previous algorithms used for brain tumor segmentation using MRI of the brain. The technique of grouping similar regions or segments of an image is known as image segmentation. Image segmentation is commonly used to find objects and boundaries in images. More precisely, brain digital image segmentation is the process of assigning a label to every pixel in an image that distinguishes a malignant component from a non-cancerous part. Maksoud et al. [10] proposed a methodology for brain tumor segmentation based on a hybrid-type approach, using the K-means clustering approach in combination with the Fuzzy c-means algorithm. The K-Means algorithm takes less time to compute than the Fuzzy c-means technique but the latter can predict tumor cells faster and more accurately. Melegy et al. [11] used the fuzzy technique to segment brain tumors. This method was developed using the FCM methodology. The suggested PIGFCM algorithm divides the brain MRI volume into basic tissues. The main tissues include the following parts: cerebrospinal fluid (CSF), white matter (WM), gray matter (GM), and background. Previous knowledge-based information improved the segmentation accuracy of brain tissues and accelerated the algorithm to the correct result. This approach dramatically improved segmentation accuracy, noise resiliency, and reaction time. Makropoulos et al. [12], suggested an algorithm for precise segmentation based on the intensity of the developing brains of infants that simulates the intensities throughout the brain. This method was exact and reliable throughout a wide variety of fetal ages. Hamamci et al. [13], proposed a seeded tumor segmentation approach based on cellular automata. The cellular automata technique has been presented to find the smallest path in graph theory. Validations were conducted using both clinical and artificial datasets. The tumor-cut method was used to further divide tumor tissue into necrotic and augmenting sections. The suggested technique highlighted the reduction in the method's sensitivity to initialization, robustness to diverse and heterogeneous tumor categories, and computational performance. Wilson and Dhas [14] used K-means and Fuzzy c-means to recognize the iron in brain SWI. The SWI for brain iron is compared using the K-means and FCM approaches. Experiments performed on Fuzzy c-means showed that the iron areas are more obvious than the result of the K-means method on the image. The main problem with this strategy was that the two procedures are not combined to gain the benefits of both. Sheela and Suganthi [15] introduced Greedy Snake Model and Fuzzy c-means optimization in their research in order to provide an effective automated brain tumor segmentation method. This method first explored the approximate region of interest (ROI) using two-level morphological reconstruction such as dilation and erosion to remove the non-tumor section. In the Greedy Snake approach, a mask was produced and degraded to enhance segmentation precision. The greedy snake model calculates new tumor borders by utilizing the mask border as the snake's primary contour. These limitations were more precise in areas with sharp edges and less accurate in areas with ramp edges. The Fuzzy c-means technique is used to improve the incorrect borders and generate the correct segmentation result. Fuzzy C means clustering, created by Patil et al. [16], firstly uses contrast enhancement in order to enhance the quality of the brain MRI image, and morphological operations are provided for removing the skull. Secondly, the result is entered into the Fuzzy c-means clustering, then a feature extraction approach combining GLRLM and GLCM is presented. The SVM classifier separates tumor and normal brain images based on retrieved features. The suggested approach detects tumor and non-tumor images. C. Narmatha et al. [17] proposed a fuzzy brainstorm optimization approach toward classifying MRI images. This approach combined both fuzzy and brainstorm algorithms. Brainstorm optimization focused on cluster centers and gave them the most priority. This approach might slip into the local optimum, similar to any other swarm approach. The fuzzy executed numerous iterations to offer an ideal network topology, and the brainstorm optimization delivered satisfactory results. In this research, they used BraTS 2018 dataset. Zahra Shahvaran et al. [18] used k-means clustering to detect brain tumors, then the active contour model based on morphological areas was employed for tumor detection, using a primary contour determined according to the border of the observed brain tumor areas. Morphological operators are used sequentially to evolve the contour. Local image intensities are modeled using a Gaussian distribution. BraTS 2013 was used to evaluate this approach. This method had better performance for tumor detection compared to other contour-based techniques.

Sajid et al. [19] proposed a fully automated deep learning method for brain tumor segmentation. They created a hybrid model that combined the effectiveness of a two-stream parallel network with a three-path network. and efficient. This model was designed to take into consideration both contextual and local data in order to address the problem of unbalanced data. To achieve this, a two-phase training process was used. Ma et al. [20] proposed a new method for automated brain tumor segmentation of MR images. In this approach, a multiscale patch-driven active contour model is combined with concatenated and connected random forests.

Lankton et al. [21] suggested a reformulation of the Chan-Vese model and the Yezzi model [22]. Instead of relying on global image information, this approach focused on localized methods for more effective contour localization. A Local Binary Fitting (LBF) model was developed by Li et al. [23] that utilized a kernel function to incorporate local intensity image details. This method involved implicit active contours driven by the energy derived from local binary fitting. A Local Gaussian Distribution Fitting (LGDF) was developed by Wang et al. [24] in order to separate the regions based on mean intensity and variance, the approach used a Gaussian distribution to define the local neighborhood. LGDF was employed in region-based Active Contour Models (ACMs) and was widely used in many fields, including medicine. Ilunga-Mbuyamba et al. [25] presented a localized active contour model with background intensity compensation for automatic MR brain tumor segmentation. The method effectively handled variations in background intensity and foreground objects in medical images. Compared to the traditional localized mean separation active contour model, this approach improved accuracy and reduced computation time.

In this work, we propose a novel approach that combines the power of morphological reconstruction with an active contour algorithm to achieve enhanced object analysis in post-processing. This integrated approach leverages the advantages of both techniques to achieve enhanced object representation, accurate boundary detection, precise measurements, noise reduction, adaptability, and time efficiency. Additionally, Fuzzy c-means clustering has been used to enhance the accuracy of brain tumor segmentation. Median filtering is also applied to remove noise from input data, which helps FCM provide results in a short time. We demonstrate the effectiveness of our approach on various datasets of brain tumor images and show that it outperforms traditional post-processing methods in terms of accuracy, time efficiency, and reliability.

3 Proposed algorithm

The K-means technique is used by several medical image segmentation systems to detect a brain mass tumor [52].  On large datasets, the K-means algorithm runs quickly, however, it suffers from insufficient tumor detection, mainly if the tumor is malignant. In contrast, other methods use the Fuzzy c-means algorithm since it maintains more details from the main image in favor of finding aggressive tumor cells more reliably than the K-means method [53].

The Fuzzy c-means algorithm is useful in our suggested medical segmentation system. Algorithm 1 shows the pseudo-code for identifying tumors in the brain from MR images. Furthermore, As shown in Fig. 1, our method consists of three stages: 1) pre-processing, 2) clustering, and 3) post-processing.

Fig. 1
figure 1

Flowchart of the proposed method for tumor detection

Algorithm 1
figure a

The pseudo-code for brain tumor detection from MR images

3.1 Pre-processing stage

This stage is executed by performing several preliminary pre-processing steps on the image before any particular processing. Image pre-processing decreases noise and improves the brain's MR image for further processing. Since brain images are more vulnerable; they should preferably have minimum noise and the highest possible quality. Therefore, this process consists of several steps:

3.1.1 Histogram matching

In image processing, histogram matching is a technique used to change an image so that its histogram matches a pre-determined histogram [51]. To do this, an image with appropriate contrast is selected as a reference, and the histogram of the input image is then matched to it. In the context of detecting tumors in medical images, the reference image used must have enough contrast to clearly identify the tumor area in the input image.

3.1.2 Median filtering

The most often used filtering technique is median filtering, which filters distortion and artifacts without sacrificing key properties such as edge information. Nonlinear median filters are used to effectively remove noise while maintaining edges. The median filter approach shown in Eq. 1 is based on replacing each pixel's gray-level with the median of the pixels in the adjacent neighborhood.

$${I}_{\mathrm{out}}[x,y]=\mathrm{median}\left\{{I}_{\mathrm{in}}[\mathrm{i},\mathrm{j}],\left(i,j\right)\in k\right\}$$
(1)

where k is a neighborhood chosen by the user and centered on the image's position [x,y]. The "window" refers to the order of neighbors, and it moves across the entire image pixel by pixel. The median is calculated by first numerically ordering all of the pixel values in the window, then, the desired pixel is replaced with the median pixel.

3.1.3 Unsharp masking

A way to create an image with well-defined edges is through the use of non-sharp filters. This method involves applying a smoothing filter to the main image and then subtracting the smoothed image from the original image. The result is an image with sharp edges, which is then added back to the original image. The specific smoothing filter affects the final result. For example, the result of using the Gaussian filter is better than the box filter, but the result of both amplifies the noise. Another leading challenge is what coefficient of high-frequency information (this image is obtained by reducing the smoothed version of the original image known as a mask) should be added to the original image. This amount is different depending on the images. Another issue is the effect of kernel size in filters such as box and median, which adds more noise to the image by increasing the size. An additional method of sharpening the edges is the direct approach of finding high-frequency information and adding it to the image. Applying the Laplacian operator to the image results in obtaining high-frequency information, and subtracting (adding) it to the image leads to the sharpening of the edges.

3.2 Clustering

One of the most well-known algorithms, FCM, develops an optimal cluster pattern through iteration by minimizing an objective function based on cluster center positions and membership. It enables the division of available sets of points of power (n) by a given number of fuzzy groups. A distinguishing aspect of the technique is the calculation of a fuzzy membership matrix, W = {wik}, made up of the membership grade of the pattern \({x}_{k}\) to each cluster (i). Therefore, points at the cluster's edge with lower membership degrees may be included in the cluster to a smaller extent than points in the cluster's center. Considering a set of clusters (c), FCM separates the info X = {x1, x2, …, xn} into C-fuzzy clusters including centroids that are consistent with V = (v1, v2, …, vc) which minimizes the objective function's value with Eq. 2.

$$F\left(W,V\right)={\textstyle\sum_{i=1}^c}{\textstyle\sum_{k=1}^n}\left(W_{ik}\right)^m\cdot\left\|x_k-v_i\right\|^2,w_k\in\left[0,1\right],i=\overline{1,c,}k=\overline{1,n,}1\leq m<\infty$$
(2)

where the parameter m shows the fuzzy exponent and m \(\in\) (1, ∞) and \(\left\|{\boldsymbol x}_{\mathbf k}-{\boldsymbol v}_i\right\|\) is the Euclidean norm between \({\mathbf{x}}_{k}\) and \({\mathbf{v}}_{i}\), \({\mathbf{v}}_{i}\) is the center of the ith cluster, each element of \({w}_{i,k}\), defines the degree to which element, \({\mathbf{x}}_{k}\), belongs to a cluster, \({\mathbf{v}}_{i}\).

$$\begin{array}{cc}w_{ik}=\left({\textstyle\sum_{j=1}^c\left(\frac{\left\|{\boldsymbol x}_k-{\boldsymbol v}_i\right\|}{\left\|{\boldsymbol x}_k-{\boldsymbol v}_j\right\|}\right)^{2\cdot\;\left(m-1\right)}}\right)^{-1}, &{\textstyle\sum_{i=1}^c}w_{ik}=1\end{array}$$
(3)
$${\mathbf{v}}_{i}=\frac{{\sum }_{k=1}^{n} {\left({w}_{ik}\right)}^{m}\cdot {\mathbf{x}}_{k}}{{\sum }_{k=1}^{n} {\left({w}_{ik}\right)}^{m}}$$
(4)

Every time the FCM clustering iterates, matrix W is created using Eq. 3, and Eq. 4 computes the related cluster centers. The square error in Eq. 1 is then calculated. The algorithm terminates when either the error or the tolerance value is reached. The performance index's membership grades are controlled by the number m. The partition grows fuzzier as m increases and if m → the degree of membership for each object in each cluster is the same.

Considering that the number of clusters must be determined using the number of white matter, gray matter, cerebrospinal fluid, and tumor areas, the number of areas has been considered four. After calculating the degree of belonging of each pixel, it is related to the cluster that has the highest degree of membership. To find the area related to the tumor, considering that this area has the highest brightness, the average gray levels of each cluster are calculated, and the cluster with the highest value is considered the tumor cluster. The rest of the clusters are attributed to other parts of the brain according to the volume of the samples inside them.

3.3 Morphological reconstruction

Morphological operation is a broad category of image processing procedures that process images depending on their size and shape. A morphological operation adjusts each pixel in an image depending on the values of neighboring pixels. By selecting the local size and shape, a morphology operation sensitive to specific shapes in the input image can be created. The most basic morphological operations are dilation and erosion, which aid in performing various operations in image processing [54]. The morphological operation of the binary image A by the structuring element B is defined in Table 1.

Table 1 Morphological operation

An opening operation is described as an erosion followed by dilation, and a closing operation is an opening performed in reverse using the same structuring element. Morphological reconstruction aims not only to reduce false positives but also to increase true positives. For this purpose, we first remove the small non-tumor areas in the image related to the tumor cluster with the opening operator and then use the closing operator to eliminate the effect of the opening operator on the tumor area. Morphological reconstruction operations require two images which are marker and mask images. The mask image is selected as the initial image. The marker image is obtained by performing morphological opening and closing operations on the candidate regions acquired in the previous step and subtracting them from the initial image. The difference between the reconstructed image and the initial image is considered the tumor regions.

3.4 Fill regions and use the binary image in active contour

In recent research, active contour models (ACM) have been used for image segmentation. Active contour models are based on the surface evolution theory and geometric flows. Snakes are known as active control and are initially made available in 1987 by Kass et al. [26]. Active contour models are used for edge detection, shape modelling, motion tracking, medical image analysis, and especially the segmentation of objects [27, 28].

In the active contour method, the contours of an image are changed based on an energy function derived from the image data to minimize energy and accurately place them on the object's boundary. The energy function is related to a curve, the goal is to find the object's boundary by minimizing the energy function. The active contour models work by evolving the curve to identify objects within the image. The contours change shape according to the features present in the image [29].

In general, active contour models can be divided into two groups: a) edge-based models and b) region-based models. Each of these strategies has advantages and limitations. Region-based active contour models use statistical data of the image in curve evolution but edge-based active contour models use image edge and gradient data. Region-based active contour models have more advantages than edge-based models. One of the most famous region-based models is the ChanVese model [30], which has been used in this study.

4 Experimental results

Implementation of all steps is done using MATLAB 2018. We run our experiments on a PC (Intel Core i7) with 16 GB of RAM and an NVIDIA/(1 GB VRAM) VGA card.

4.1 Data sets

The BraTS 2012 and 2013 dataset is a collection of multimodal brain tumor images from synthetic and real patients. The training and testing sets are different for the BraTS 2012 and 2013 datasets. For the BraTS 2012 dataset, the training set consists of 30 patients with HG and LG and includes the ground truth segmentations. The testing set consists of 15 real patients with HG and LG and does not include the ground truth segmentations. For the BraTS 2013 dataset, the training set consists of 10 real patients and includes the ground truth segmentations. The testing set consists of 10 real patients with HG and LG and does not include the ground truth segmentations. The testing set is used for ranking the algorithms on the BraTS website. The dataset also provides manual segmentations of the tumor regions for each image. The segmentations have four labels: necrosis (1), edema (2), non-enhancing tumor (3), and enhancing tumor (4). The segmentations are used as ground truths for evaluating the performance of brain tumor segmentation algorithms. Figure 2 shows some sample images from the dataset with different modalities and tumor types.

Fig. 2
figure 2

The image patches show tumor structures in different MRI modalities: FLAIR (A), T2 (B), and T1c (C). The segmentations are combined to generate the final labels for the dataset (D): edema (yellow), non-enhancing solid core (red), necrotic/cystic core (green), and enhancing core(blue) [31]

4.2 Evaluation

A valid evaluation method provides quantitative and comparative information necessary for performance evaluation. The criteria of Sensitivity, Dice score, Accuracy, and Precision have been used in the proposed algorithm. These factors are mainly relying on the value of TP, TN, FP, and FN.

Where TP, TN, FP, and FN can be described as follows:

  1. (i)

    TP is a tumor that is real and has been properly identified.

  2. (ii)

    TN is a tumor that does not exist and cannot be found.

  3. (iii)

    FP is a tumor that is not present but is detected.

  4. (iv)

    FN is a tumor that is present but not found.

    $$\mathrm{Dice}=\frac{2\mathrm{TP}}{2\mathrm{TP}+\mathrm{FP}+\mathrm{FN}}$$
    (5)
    $$\mathrm{Sensitivity }= \frac{\mathrm{TP}}{\mathrm{TP}+\mathrm{FN}}$$
    (6)
    $$\mathrm{Accuracy}= \frac{\mathrm{TP }+\mathrm{ TN}}{\mathrm{ TP }+\mathrm{ FP }+\mathrm{ TN }+\mathrm{ FN}}$$
    (7)
    $$\mathrm{Precision}= \frac{\mathrm{TP}}{\mathrm{TP}+\mathrm{FP}}$$
    (8)
    $$\mathrm{Hausdroff\, Distance}\left(\mathrm{A},\mathrm{ B}\right)=\mathrm{max}\left\{\mathrm{h}\left(\mathrm{a},\mathrm{ B}\right)\right\}=\mathrm{max}\{\mathrm{min}\{\mathrm{d}(\mathrm{a},\mathrm{ b})\}\}$$
    (9)
    $$\mathrm{Jaccard}\left(\mathrm{A},\mathrm{ B}\right)=\frac{\mathrm{TP}}{\mathrm{ TP }+\mathrm{ FP }+\mathrm{ FN}}$$
    (10)

The Dice score is used to calculate the overlap between manually created ground truth masks and automatically segmented tumors in medical imaging. It is expressed as Eq. (5). Its main application is in the evaluation of segmentation models. Sensitivity is another metric used to predict real positive cases that are predicted as positive. It is also known as recall and can be expressed as Eq. (6). Accuracy is a statistical measure that indicates how well the predicted value matches the actual value. It is used in the method of analyzing the system’s performance. It is expressed as Eq. (7). In addition, the most common method of evaluation is the accuracy of the tumor diagnosis. A high level of accuracy indicates that the classification of MRI images is accurate and therefore, the proposed algorithm is effective. Precision is a measure of how well a model can identify true positive pixels that belong to a cluster compared to all the pixels that the model predicted as positive which is shown in Eq. (8). The results of each technique are recorded in Tables 2 and 3 according to Precision, Sensitivity, Accuracy, and Dice that are mentioned before and represented. The Hausdorff distance can be calculated using Eq. (9), where A and B are two sets of points, h(a, B) is the minimum distance between a and B, and d(a, b) is the Euclidean distance between points a and b. In the context of brain tumor segmentation, the Hausdorff distance metric measures how well the boundary voxels of the segmented regions match between the ground truth and the results of the algorithms used for brain tumor segmentation. Furthermore, we used the Jaccard coefficient. It is a measure of similarity between two sets of data and can be expressed as Eq. (10).

Table 2 Comparison of the average computation time among proposed methods and other methods using the BraTS dataset
Table 3 Comparison of BraTS 2012 dataset using SVM-based and ERT-based classifies, in contrast, FCM + MR + AC-based

4.3 Results and discussion

The output results of the figure are discussed in this section. The proposed tumor segmentation method is validated by performance parameters such as accuracy, specificity, sensitivity, and dice. In this technique, Image preprocessing reduces noise and increases the image's clarity. FCM clustering is used to initially identify the tumor areas. Also, morphology operators based on reconstruction are used to properly refine the appeared frills in the images. Finally, by applying active contour, the boundaries of the tumor became more precise. The results in Table 2 demonstrate the reliability and accuracy of our method. We discuss the proposed method in the following.

In the pre-processing step, the images used in the study are 16 bits, and no reduction in gray levelshave been made to prevent information loss. Figure 3a shows the image considered as a reference in the histogram matching step. Figure 3c shows the result of histogram matching on the input image. The tumor region is completely uniform and includes all the tumor regions that are shown in the ground truth. In the next step, Fig. 3d and e illustrate the noise removal and contrast improvement utilized for the image. MRI is often affected by noise and artifacts that need to be removed before the image can be processed to determine whether or not it has a tumor. The median filter is the preferred tool for filtering noise in MRI brain images [32]. Unlike other filters, this one doesn't blur or smooth out the image's edges, maintaining the image's sharpness.

Fig. 3
figure 3

Results of pre-processing steps: (a) reference image for histogram matching (b) input image (c) histogram matching (d) noise removing (e) unsharp masking

In the clustering step, the FCM clustering algorithm assigns membership to each data depending on its distance from the cluster's center. If there is less distance between the cluster's center and the data point, the data point is more likely to be a member of that cluster. The number of clusters must be determined using the number of white matter, gray matter, cerebrospinal fluid, and tumor areas; therefore, the number of clusters has been considered 4. For better understanding, in Fig. 4d, the pixels whose degree of membership is less than 0.6, which may belong to several categories, are shown in yellow. These pixels represent the regions where the segmentation is uncertain, and where different tumor structures may overlap or coexist with other brain tissues, such as white matter, gray matter, and cerebrospinal fluid. In Fig. 5, the clusters are determined according to the average gray levels and the number of pixels in each category. The order of the clusters based on the average of pixels gray level follows this sequence: tumor, white matter, gray matter, and cerebrospinal fluid, which means that the brightest cluster is considered a tumor. The tumor cluster has a much higher gray level than the other clusters, indicating its high intensity and contrast in the MRI images. Figure 5e also shows that the tumor cluster has a lower pixel count than the other clusters, indicating its small size and shape.

Fig. 4
figure 4

The steps of Fuzzy c-means: (a) unsharp masking (b) Mask (c) the multiple of the unsharp masked image by the mask (d) Fuzzy c-means results (e) the multiple of the Fuzzy c-means results by the mask

Fig. 5
figure 5

Fuzzy c-means clusters: (a) all clusters (b) white matter (c) gray matter (d) cerebrospinal fluid (e) tumors

According to Fig. 6, the tumor cluster includes non-tumor areas in addition to the tumor area. To partially remove the above-mentioned areas, firstly, the opening operator is applied to the image. Then, the closing operator is applied to the image to cause the remaining areas to completely cover the tumor.

Fig. 6
figure 6

Result of morphological opening and closing on the tumor

Figure 7 illustrates the steps of morphological reconstruction and the difference between the reconstructed image and the original image is considered a tumor area. After morphological reconstruction, the issue is that the border of the tumor areas is not accurate enough. As shown in Fig. 7d, the boundaries of the tumor are still not exact. To improve the tumor boundaries, after filling the empty areas, the boundaries of the tumor are preceded by active contour. As the output of this step is shown in Fig. 7e, the boundaries obtained by the active contour method have been improved. In the following, the output of the proposed approach is shown in detail in Fig. 8.

Fig. 7
figure 7

The results of the morphology reconstruction: (a) input (b) marker (c) morphological reconstruction (d) imprecise boundaries (e) active contour (f) ground truth

Fig. 8
figure 8

The segmented and area-extracted result of a brain MR image from BraTS 2012: (a) input (b) ground truth (c) remove noise (d) unsharp masking (e) membership (f) Fuzzy c-means (g) white matter (h) gray matter (i) cerebrospinal fluid (j) tumor

The proposed technique was used to produce the experimental results for the segmented regions for the three classes of WM, GM, and CSF, and for the extracted tumor region are given in Fig. 8. The figure shows the different steps and outputs of the proposed technique applied to a brain MR image. Figure 8a shows the input image, and Fig. 8b shows the ground truth segmentation. Figure 8c shows the result of removing noise from the input image using a median filter. Figure 8d shows the result of enhancing the edges and details of the image using unsharp masking. Figure 8e shows the result of computing the degree of membership for each pixel using a Fuzzy c-means. Figure 8f shows the result of clustering the pixels into four groups using the Fuzzy c-means algorithm. Figure 8g, h, and i show the result of extracting the WM, GM, and CSF regions from the clustered image, respectively. Figure 8j shows the result of extracting the tumor region from the clustered image using a morphological reconstruction and active contour. The figure demonstrates that the proposed technique can effectively segment and extract brain tissues and tumors from a noisy and low-contrast image. In addition, the other images from BraTS 2013 that are shown in Figs. 9, 10, and 11 are added.

Fig. 9
figure 9

The segmented and area-extracted result of a brain MR image from BraTS 2013: (a) input (b) ground truth (c) remove noise (d) unsharp masking (e) membership (f) Fuzzy c-means (g) white matter (h) gray matter (i) cerebrospinal fluid (j) tumor

Fig. 10
figure 10

The segmented and area-extracted result of a brain MR image from BraTS 2013: (a) input (b) ground truth (c) remove noise (d) unsharp masking (e) membership (f) Fuzzy c-means (g) white matter (h) gray matter (i) cerebrospinal fluid (j) tumor

Fig. 11
figure 11

The segmented and area-extracted result of a brain MR image from BraTS 2013: (a) input (b) ground truth (c) remove noise (d) unsharp masking (e) membership (f) Fuzzy c-means (g) white matter (h) gray matter (i) cerebrospinal fluid (j) tumor

4.4 Computation time

As shown in Table 2, it is important to notice that the FCM + MR + AC technique has the lowest computation time compared to previous methods for performing brain tumor segmentation. This method achieves more promising results and reduces the running time by using a combination of fuzzy c-means, morphological reconstruction, median filtering, and active contour. The proposed method exhibits a considerable reduction in computation time as compared to the LACM-BIC solution, with a speed advantage of approximately six times.

The median filter for pre-processing is a tool of choice for filtering noise in MRI brain images. By removing noise from the input data, median filtering can help FCM converge faster and produce more accurate clusters. The reason behind this significant difference can be attributed to the iterative nature of the Fuzzy c-means solution which leads to computationally expensive processing whereas by using fewer clusters and a quicker termination condition, it can speed up the image processing for brain tumor segmentation. Conversely, the proposed method employs a non-iterative and quick-to-compute morphological step, resulting in reduced computational overhead. These findings also hold true for brain tumor images of varying types. Using region-based active contours, also known as Chan-Vese models, can reduce computation time by exploiting global information about the image.

4.5 Experimental results

Table 3 shows the results for complete tumor detection on the BraTS 2012 dataset. 30 images from the training dataset are utilized to test the suggested approach. The proposed method is compared with SVM and ERT methods [39]. Results present the evaluation measures for SVM, ERT, and FCM + MR + AC, respectively. It is clear that FCM + MR + AC results in a slightly improved performance, compared to that of SVM and ERT, with an overall classification Precision of 89.09%, Sensitivity of 88.09%, and Dice 0.88% for ERT, Accuracy of 83.79, the Sensitivity of 82.72 and Dice 0.83% for SVM and 92.05%, 92.10% and 0.92 for FCM + MR + AC, respectively. Furthermore, we use the Jaccard coefficient and Hausdorff distance that averages are 0.86 and 3.60 respectively. The dice score of ERT, SVM classifiers, and FCM + MR + AC for the BraTS dataset is presented in Table 4. It can be seen that result for FCM + MR + AC is more accurate than that of SVM-based and ERT-based. In addition, the proposed algorithm is evaluated on BraTS 2013 and achieves excellent results in terms of commonly used metrics such as Sensitivity, Accuracy, Dice score, Jaccard, and Hausdorff distance with values of 93.15%, 99.56%, 0.93, 0.87, and 3.21, respectively.

Table 4 Comparison of Dice score for BraTS 2012 dataset (30 scans) using SVM and ERT methods and FCM + MR + AC

4.6 Comparative analysis

Regarding all the evaluations in Tables 5 and 6, it can be seen that the performance of the FCM + MR + AC method is superior to other algorithms, and a similar value is obtained only in Reza's method [40].

Table 5 Comparison of the proposed method with several other related methods using the BraTS dataset 2012
Table 6 Comparison of the proposed method with several other related methods using the BraTS dataset 2013

In Fig. 12, it can be seen that all evaluation parameters of our method are much higher than that of SVM-based and ERT-based. Figures 13 and 14 show the bar graph comparing different Dice methods.

Fig. 12
figure 12

Comparison of Dice, Sensitivity, and Precision for the proposed method, SVM, and ERT method

Fig. 13
figure 13

Comparison of the Dice score of the proposed method with other methods on BraTS 2012

Fig. 14
figure 14

Comparison of the Dice score of the proposed method with other methods on BraTS 2013

We emphasize the significance of the pre-processing stage in our study, which is MRI histogram matching. This is especially crucial when using the BraTS dataset, which contains data from multiple scanners and multicenter [39]. With the purpose of brain tumor segmentation and the regionalization of brain tumor segments in this study, FCM fuzzy clustering has been used to identify and extract the tumor region. Morphology reconstruction has also been used to reduce the areas that are wrongly placed in the tumor cluster, which resulted in a positive effect. In the last step, the use of active contour has resulted in obtaining better boundaries for the tumor area.

5 Conclusion and future work

This study proposes a novel algorithm for the automatic detection and segmentation of brain tumors from MRI images. The algorithm combines Fuzzy c-means clustering and morphological reconstruction to achieve fast and accurate tumor segmentation. The Fuzzy c-means clustering is used to partition the image into clusters based on the intensity values, and the morphological reconstruction is used to refine the tumor cluster by removing the non-tumor regions. The algorithm is applied to the BraTS 2012 and BraTS 2013 data sets, which contains multimodal MRI images of brain tumors with different grades and types. The proposed algorithm is effective and robust, as demonstrated by its excellent performance in terms of commonly used metrics such as Sensitivity, Accuracy, Dice score, Jaccard, and Hausdorff distance for BraTS 2012, 92.10%, 99.06%, 0.92, 0.86, and 3.60 and BraTS 2013, 93.15%, 99.56%, 0.93, 0.87, and 3.21. The diagnosis can be improved by using the proposed algorithm which provides valuable information and treatment of brain tumors, which are among the most serious and challenging diseases.

In future work, we plan to use U-net [50], a state-of-the-art deep learning network for brain tumor segmentation that can learn complex features from MRI images and perform end-to-end segmentation with high accuracy and robustness. We will compare the performance of U-net with our proposed method and investigate how to improve it further with data augmentation, transfer learning, or self-supervised learning techniques.