Accurate Brain Tumor Detection and Classification System Based on MRI Images Using Deep Learning Technology

Accurate Brain Tumor Detection and Classification System Based on MRI Images Using Deep Learning Technology

Bahaa D. Jalil Bashra Kadhim Oleiwi* Layla H. Abood

College of Control and Systems Engineering, University of Technology - Iraq, Baghdad 19006, Iraq

Corresponding Author Email: 
bushra.k.oleiwi@uotechnology.edu.iq
Page: 
1347-1353
|
DOI: 
https://doi.org/10.18280/jesa.580704
Received: 
24 December 2024
|
Revised: 
13 June 2025
|
Accepted: 
23 June 2025
|
Available online: 
31 July 2025
| Citation

© 2025 The authors. This article is published by IIETA and is licensed under the CC BY 4.0 license (http://creativecommons.org/licenses/by/4.0/).

OPEN ACCESS

Abstract: 

Brain tumors are a serious and aggressive disease, affecting both children and adults. Non-invasive and accurate diagnosis using Magnetic Resonance Imaging (MRI) images is crucial for effective treatment planning. This study aims to develop a Convolutional Neural Network (CNN) system for the detection and classification of brain tumors based on a Kaggle dataset named "Brain Tumor Classification MRI," containing three tumor types and a no-tumor category. It consists of MRI scans as a set of slices of four classes: images of 3 types of brain tumors and normal cases.  The number of MRI data is 3264 images, 2764 brain tumor cases, and 500 images of normal patients). The research process involved dataset collection, image pre-processing, and exploration of various CNN design options, such as optimizers (Adam, AdaDelta, and SGD), layer configurations, receptive field sizes, stride, kernel, padding, and classifiers. The proposed CNN system achieved a testing accuracy of 100% and demonstrated high efficiency in recognizing brain tumors. The findings suggest that the developed deep learning approach has the potential to improve non-invasive brain tumor diagnosis and contribute to clinical decision-making.

Keywords: 

brain tumor detection and classification, deep learning, Convolutional Neural Network (CNN), medical image analysis, Magnetic Resonance Imaging (MRI)

1. Introduction

About 90% of all primary cancers in both children and adults are aggressive brain tumors [1]. A brain tumor can be classed as benign, malignant, or pituitary and approximately 11,700 people are diagnosed with one each year [2]. Despite MRI is considered the most effective method for detecting brain cancer, many MRI images are created by scanning procedures. But the demand to increase the life expectancy of people with brain tumors, appropriate treatment planning and precise diagnosis is required and must be carried out. The imaging data will be examined by a radiologist. However, manual examination can be inaccurate due to the complexity and features of brain tumors [3]. Brain tumors are classified and a biopsy is carried out, which is uncommon before a final brain operation. CNN is a form of algorithm utilized in deep learning that efficiently tackles tasks and has proven effective in various applications like recognizing objects and categorizing pictures, in natural language processing [4]. Technological developments and machine learning have made it possible for radiologists to diagnose cancers without performing invasive treatments. Recently, deep learning has become increasingly popular due to its superior accuracy when trained on massive data and feature extraction automatically.  The deep learning algorithms produced important results in the identification and classification of brain cancers [5, 6]. Numerous research projects delve into the detection methods of brain tumors. In this discussion we will explore some of the findings in this field.

In order to classify brain tumors, a microcapsule model was proposed based on the high accuracy of 86.56% [7]. Pre-trained or transfer learning models were applied to classify tumors, using ResNet-50 to accomplish excellent performance compared with inceptionv3 and VGG-16 [5]. A hybrid method was proposed that combined the VGG-net, ResNet, and LSTM networks for tumor cell categorization, with 71% and 84% accuracy on Alexnet and the ResNet model, respectively [8]. Tumor classification used three machine learning models with 88% accuracy [9]. A modified CNN (CapsNet) based on capsule networks for classifying cancers is introduced in the study [10]. The suggested CapsNet utilized spatial interaction based on the tumor along with the surrounding cells. The suggested CapsNet accomplished an accuracy of 90%, an enhancement over SVM's accuracy of 88%. The multiple-class brain tumor image classification model is based on the adversarial generative model [11]. The proposed model contains six enormously complex levels. Added to this are approaches to enhance the quality of the data resulting in an accuracy rate of 96,25% achieved through both random divisions. A detection and classification models based new architectures of CNN have been introduced and utilizing different layers, optimization filters, parameters, different histogram techniques with multi-levels of improvement, OpenCV library, and Wiener filter for detection, classifying, and improving the images contraction [12-22]. Fingerprints detection and identification model using global and local fingerprint datasets is presented [12, 13] while disease detection and identification model utilizing X-ray image dataset global and local dataset is performed [14-16], and human iris detection and identification model based on global and local human iris dataset [17]. Usage of deep transfer learning models were suggested to recognize medicinal plants. As a result, Bit_s-r50x1, Inception_v3, Inception_ResNet_v2, Nasnet_large, ResNetv1_152, and mobilenet_v2_130_224 were the six transfer learning models investigated and evaluated. The Indonesia medicinal plant was used [18]. CNN and a forest fire dataset for drone applications to create a surveillance system were utilized, for identifying and categorizing uncontrolled forest fires [19].

Concerning all of the studies mentioned above, many studies worked on brain tumor detection and classification differently and predicted some promising findings based on their dataset.

Although many earlier studies in classification models achieved great performance and accuracy, they also incorporated a number of image preparation procedures that might not be appropriate for all datasets including brain tumors. The experiments mentioned above have all been conducted on fixed-size and type photographs without the use of noise-removal filters, strategies for enhancing the image quality, or sophisticated procedures. However, there is still room to create a reliable algorithm that makes use of multiple criteria. Different features will be required to find highly accurate results and improve the categorization rate of brain cancers.

The study’s main achievement lies in creating a CNN architecture that utilizes the MRI dataset, for brain tumor classification from Kaggle to detect and classify types of brain tumors. The key steps or objectives in this concept are dataset collection, image pre-processing, and then an investigation of the various design options for CNN-based brain tumor recognition. Examples of these options include different types of optimizers such as Adam, AdaDelta, and SGD, various numbers of convolutional and pooling layers, various sizes of receptive fields in CNN, stride, kernel, padding, and different types of classifiers.

The sections in this paper are structured as follows: The suggested methodology described in Section 2, which includes the dataset description and collection, images pre-processing and data augmentation, a summary of network architecture for use in the detection and classification of three types of brain tumor types and training and testing network. The results and discussion of the proposed methodology are presented in Section 3, and Section 4 gives the main conclusion of this study and the discussion of its findings, and it describes the future work of directions to new research which can be taken into consideration.

2. Methodology

2.1 Dataset description

The image data used for this problem is the Kaggle dataset named brain tumor classification (MRI) [3]. It consists of MRI scans as a set of slices of four classes: images of 3 types of brain tumors and normal cases. The folder contains MRI data (3264 images, 2764 brain tumor cases, and 500 images of normal patients). These images are classified into two folders training and test folders. Each folder contains four subfolders, including MRI images of the respective tumor group. Tumor types are divided into three types in terms of meningioma, glioma, and pituitary adenoma, and all datasets were obtained in three planes coronal, axial, and sagittal planes, as described in Figure 1. Figure 2 indicates some samples of the original dataset and the structure of folders for splitting images and Figure 3 depicts an MRI image shows a brain metastasis in the right cerebral hemisphere where the tumor is highlighted in red color [1].

Figure 1. Illustration of tumor classification in dataset

Figure 2. Dataset’s folders structure

Figure 3. MRI image with highlighted brain tumor

2.2 Images augmentation and pre-processing

The dataset contains MRI images in Red, Green, and Blue (RGB) colors in different sizes and jpg format. These images will be fed to the input layer in the network [23]. In the image preprocessing, the RGB images are converted into grayscale with pixels from 0 to 255 and resized to 512×512 pixels. In order to aid in the simplification of algorithms and the elimination of the complexity associated with computational needs, images are transformed to grayscale. Images with better contrast are produced using the histogram equalization.

The first step involves gathering, preprocessing, and augmenting the dataset. Data augmentation, contrast-limited adaptive histogram equalization (CLAHE) technique is used to enlarge and improve the dataset.

The size and number of images in the training and testing folders have been standardized as uniform dimension images, as shown in Figures 4 (a) and 4 (b).

By changing copies of the current data or creating new copies of the dataset artificially using the existing dataset, the data augmentation will be used and is a group of approaches for increasing the amount of the dataset used for system training. Expanding the dataset (data augmentation) is when you increase the amount of data utilized to train a model. Deep learning models need extensive training data to generate accurate predictions and such data is not always accessible. The process of adding more data to the initial or original data results in a model that can be applied to a broader range of situations. Data augmentation serves as a common technique in computer vision yet it has applications across multiple domains. In data augmentation, the top two used methods, for enhancing photo data involve position adjustments like scaling and cropping well as color enhancements such as brightness and contrast modifications along, with saturation and hue adjustments. The images will be increased as part of the dataset augmentation, and some images were altered in four different ways. The image is rotated by 45 and 90 degrees, respectively, in the first and second transformations. The photos were rotated vertically as the third transformation, and color augmentation using brightness and contrast was applied as the fourth change, as demonstrated in Figure 5.

(a)

(b)

Figure 4. Samples of original dataset, (a) standardized size and number of images and (b) structure of folders for splitting images

Figure 5. Samples of augmented images

3. CNN Structure

The choice of CNN architecture should be based on a thorough understanding of the data and the task at hand, as well as experimentation and evaluation to determine the most effective approach. The complexity of the image classification problem, the amount of the dataset, the processing resources available, and the required level of accuracy all influence the CNN architecture that is selected. In Figure 6, you can see the diagram illustrating the proposed model for detecting and categorizing brain tumor. The classification of types of tumors was carried out using a CNN developed in Matlab R2020a, and after several attempts of experiments, a better CNN model was obtained. The proposed structure of the CNN gives a preferable accuracy for brain tumors classification mainly consists of 13 layers: [Input – Conv2D – MaxPool –ReLU – Conv2D - MaxPool – ReLU – Conv2D - MaxPool – ReLU – Fully connected –SoftMax– Classification], as demonstrated in Figure 7.

Figure 6. The suggested model diagram

Figure 7. Layer architecture of the CNN model

The following steps describe the CNN model architecture:

• The dataset images are resized to 512×512×1, where one is the color image channel and 512×512 is the image dimension.

• 512×512×1 is the input.

• The first convolutional layer (Conv1) contains seven 3×3 filters. On the input image, the convolutional layer's output is

$\begin{gathered}G(m, n)=(f \times h)(m, n)=\sum_j \sum_k h(j, k) \times \\ f([m-j, n-k])\end{gathered}$           (1)

where, a 2-dimensional kernel/filter size is denoted by h, and a 2-dimensional input image of (width× height× channel) is represented by f.

ReLU(x) = (max (0, x)) is the definition of ReLU, an activation function that adds nonlinearity to the system. This is followed by a 3×3 max-pooling layer.

• The second convolutional layer (Conv2) comprises of 10 3×3 filters with ReLU as an activation function, is followed by the max-pooling layer, which is 2×2.

• The third convolutional layer (Conv2) consists of 10 3×3 filters with ReLU as an activation function. A 2×2 max-pooling layer comes next.

• Flatten Layer

• FC Layer 1 = 4 fully connected layer

• The definition of the Softmax activation function is:

$\operatorname{Softmax}\left(x_i\right)=\frac{e^{\left(x_i\right)}}{\sum_{j=1}^n e^{\left(x_j\right)}}$           (2)

where, e is the base of the natural logarithm system and x is an input vector for the pre-activation value.

Table 1 shows the detailed layer configuration parameters of the proposed CNN model.

Table 1. CNN layer parameters and operational details

No.

Name Layer

Filter Size

Number of Filters

Movement is Horizontal

Movement is Vertical

1

Input

Size input imge 512×512×3

2

Convolution

3×3

7

1

1

3

Max Pooling

3×3

 

3

3

4

ReLU

2

 

2

2

5

Convolution

3×3

10

1

1

6

Max Pooling

2×2

 

2

2

7

ReLU

2

 

2

2

8

Convolution

3×3

10

1

1

9

Max Pooling

2×2

 

2

2

10

ReLU

2

 

2

2

11

Fully Connected

4 type output

12

Softmax

 

13

Classification Output

4 classes output

4. Training and Testing

The suggested methodology was built and handled with 80% of the dataset for the training phase (70% training set and 10% validation set) and 20% of the dataset for the testing phase, as presented in Figure 8.

After the augmentation and preprocessing phases, the training process begins. The training set is fed to the proposed 13-layer CNN model, which is trained using a patch size of 50, a learning rate of 1×10⁻³, the Adam optimizer, categorical cross-entropy loss, and up to 2,000 epochs as stated in Table 2. Once training concludes—either by reaching the epoch limit or by triggering early stopping—the final model weights are saved for inference. Finally, the held-out 20% test set is passed through the model (without further weight updates), and the performance is evaluated.

Figure 8. Image distribution across dataset partitions

Table 2. The used operators in CNN

Parameters

Values

The size of the patch

50

Learning_rate

1e-3

Type of optimizer

Adam

Type of classification

Categorical

Epoch

2000

5. Results and Discussion

The suggested CNN models were trained using MATLAB (version 2020) running on a desktop computer with an 4ht generation Intel (R) Core (TM) i7-4790 processor running at a speed of 3 GHz and 64 operating system with 8.00 GB RAM based on windows 10 pro and on a single GPU, NVIDIA device, GeForce GTX 1060, RAM 3GB.

Simulations were performed to evaluate the proposed system performance utilizing the collected dataset Images have been collected and quantified regarding 512×512 and 256 grayscale. Figure 9 displays the dataset patterns applied in the training phase of the system with hyperparameter values shown in Table 1.

The proposed system achieved training accuracy of 100%. Figure 10 illustrates the accuracy and loss during training phase. The accuracy of the testing phase was 100% which took 12 ms per image as average execution time. Figure 11 clearly evidences that the proposed CNN-based brain tumor categorizing system is successfully implemented, and the training and validation results showed that the overall accuracy is admirable. The results indicated that the proposed method is capable of successfully identifying brain tumor type.

Figure 9. Dataset patterns for training phase

Figure 10. The accuracy performance in training phase

Figure 11. System’s classification outcomes

Our CNN was trained solely on the Kaggle “Brain Tumor Classification (MRI)” dataset of 3264 images acquired under uniform scanning protocols, which may introduce bias and limit applicability to other patient populations or MRI machines. The preprocessing steps—grayscale conversion, histogram equalization, CLAHE, and four-fold augmentation—were tailored to this dataset and may not generalize to images with different noise levels or artifacts. Finally, the system has not been validated on other imaging modalities (e.g., CT, X-ray) or external MRI cohorts.

6. Conclusions

This study introduces a new system of brain tumor detection based on CNN structure. The classification was performed using the improved Kaggle brain tumor MRI dataset, which contains three and no tumor types. The obtained testing accuracy was 100% for the testing phase. The average execution time of the testing phase was 12 ms per image. These findings indicate the system's high generalizability and implementation speed, which can be carried out as an assistive system in decision-making for medical diagnostic radiologists. According to further work, a 3D CNN can be used, and multimodal CNN can be considered to increase the database, such as using several types of illnesses to improve the system's generalization ability. Some improvements and adjustments can be done to the CNN architecture to classify and accurately the brain tumor location during brain surgery. The performance of the proposed CNN can be examined on other medical images. The proposed idea's improvement can also involve real-time implantation for detecting the brain tumors in the operating room.

  References

[1] Brain Tumor. Key Statistics for Brain and Spinal Cord Tumors. https://www.cancer.net/cancer-types/brain-tumor/statistics. 

[2] American Association of Neurological Surgeons—Classification of Brain Tumors. https://www.aans.org/en/Media/Classifications-of-Brain-Tumors.

[3] Brain Tumor Classification (MRI). https://www.kaggle.com/datasets/sartajbhuvaji/brain-tumor-classification-mri.

[4] Jalil, B.D., Noaman Al-Hayanni, M.A. (2024). Intelligent deep learning system for enhanced pulmonary disease diagnosis through five-class mode. Revue d'Intelligence Artificielle, 38(4): 1193-1199. https://doi.org/10.18280/ria.380413

[5] Akinyelu, A.A., Zaccagna, F., Grist, J.T., Castelli, M., Rundo, L. (2022). Brain tumor diagnosis using machine learning, convolutional neural networks, capsule neural networks and vision transformers, applied to MRI: A survey. Journal of Imaging, 8(8): 205. https://doi.org/10.3390/jimaging8080205

[6] Salman, L. A., Hashim, A. T., Hasan, A.M. (2022). Automated brain tumor detection of MRI image based on hybrid image processing techniques. TELKOMNIKA (Telecommunication Computing Electronics and Control), 20(4): 762-771. http://doi.org/10.12928/telkomnika.v20i4.22760

[7] Adu, K., Yu, Y., Cai, J., Asare, I., Quahin, J. (2022). The influence of the activation function in a capsule network for brain tumor type classification. International Journal of Imaging Systems and Technology, 32(1): 123-143. https://doi.org/10.1002/ima.22638

[8] Sedik, A., El-Shafai, W., El-Hag, N.A., El-Banby, G.M., Abd El-Samie, F.E. (2025). Retinal disorder diagnosis based on hybrid deep learning models. Multimedia Tools and Applications, 1-25. https://doi.org/10.1007/s11042-024-18454-y

[9] Toufiq, D.M., Sagheer, A.M., Veisi, H. (2021). A review on brain tumor classification in MRI images. Turkish Journal of Computer and Mathematics Education (TURCOMAT), 12(14): 1958-1969.

[10] Aminian, M., Khotanlou, H. (2022). CapsNet-based brain tumor segmentation in multimodal MRI images using inhomogeneous voxels in Del vector domain. Multimedia Tools and Applications, 81(13): 17793-17815. https://doi.org/10.1007/s11042-022-12403-3

[11] Ahmad, B., Sun, J., You, Q., Palade, V., Mao, Z. (2022). Brain tumor classification using a combination of variational autoencoders and generative adversarial networks. Biomedicines, 10(2): 223. https://doi.org/10.3390/biomedicines10020223

[12] Althabhawee, A.F.Y., Alwawi, B.K.O.C. (2022). Fingerprint recognition based on collected images using deep learning technology. IAES International Journal of Artificial Intelligence, 11(1): 81-88. https://doi.org/10.11591/ijai.v11.i1.pp81-88

[13] Oleiwi, B.K., Abood, L.H., Farhan, A.K. (2022). Integrated different fingerprint identification and classification systems based deep learning. In 2022 International Conference on Computer Science and Software Engineering (CSASE), Duhok, Iraq, pp. 188-193. https://doi.org/10.1109/CSASE51777.2022.9759632

[14] Alwawi, B.K.O.C., Abood, L.H. (2021). Convolution neural network and histogram equalization for COVID-19 diagnosis system. Indonesian Journal of Electrical Engineering and Computer Science, 24(1): 420-427. https://doi.org/10.11591/ijeecs.v24.i1.pp420-427.

[15] Oleiwi, B.K., Abood, L.H., Al Tameemi, M.I. (2022). Human visualization system based intensive contrast improvement of the collected COVID-19 images. Indonesian Journal of Electrical Engineering and Computer Science, 27(3): 1502-1508. https://doi.org/10.11591/ijeecs.v27.i3.pp1502-1508

[16] Saeed, R.S., Oleiwi, B.K. (2022). A survey of deep learning applications for COVID-19 detection techniques based on medical images. Ingénierie des Systèmes d’Information, 27(3): 399-408. https://doi.org/10.18280/isi.270305

[17] Alwawi, B.K.O.C., Althabhawee, A.F.Y. (2022). Towards more accurate and efficient human iris recognition model using deep learning technology. TELKOMNIKA (Telecommunication Computing Electronics and Control), 20(4): 817-824. http://doi.org/10.12928/telkomnika.v20i4.23759

[18] Sahib, K.A., Oleiwi, B.K., Nasser, A.R. (2024). Medicinal plants recognition using deep transfer learning models. International Journal of Design & Nature and Ecodynamics, 19(5): 1501-1510. https://doi.org/10.18280/ijdne.190504

[19] Althabhawee, A.F.Y., Oleiwi, B.K. (2025). An intelligent surveillance model for wild forest fire detection using deep learning for drone application. Journal Européen des Systèmes Automatisés, 58(1): 115-120. https://doi.org/10.18280/jesa.580113

[20] Oleiwi, B.K., Kadhim, M.R. (2022). Real time embedded system for object detection using deep learning. AIP Conference Proceedings, 2415(1): 070003. https://doi.org/10.1063/5.0093469

[21] Oleiwi, B.K. (2019). Scouting and controlling for mobile robot based raspberry Pi 3. Journal of Computational and Theoretical Nanoscience, 16(1): 79-83. https://doi.org/10.1166/jctn.2019.7701

[22] Atee, H.A., Hammood, D.A., Yasari, A.K. (2022). A steganography approach based on particle swarm optimization and least significant bit in color images. AIP Conference Proceedings, 2496(1): 020018. https://doi.org/10.1063/5.0090872

[23] Sajjad, M., Khan, S., Muhammad, K., Wu, W., Ullah, A., Baik, S.W. (2019). Multi-grade brain tumor classification using deep CNN with extensive data augmentation. Journal of Computational Science, 30: 174-182. https://doi.org/10.1016/j.jocs.2018.12.003