0% found this document useful (0 votes)
15 views5 pages

ML Final Project-1

Uploaded by

Amina Bashir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views5 pages

ML Final Project-1

Uploaded by

Amina Bashir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Brain Tumor Segmentation using K-Means

Clustering and Detection usinG Convolutional


Neural Network
Kainat Tahir
Lahore, Pakistan
[email protected]

Abstract—This project focuses on detecting and segmenting The goal of this work is to develop a reliable brain tumor
brain tumors using image processing techniques. MRI scans are segmentation and detection system by combining CNNs with
processed with K-means clustering and then analyzed with a K-Means clustering. The principal aims of this study are
convolutional neural network (CNN).The research will be done
in two phases, image processing and applying neural network. to assess how well K-Means clustering performs in terms
Index Terms—Brain tumour, segmentation, K-means cluster- of preliminary segmentation, improve tumor identification
ing, Detection, CNN accuracy through the use of CNNs, and guarantee that the
method uses minimal CPU resources, making it appropriate
I. I NTRODUCTION for wider clinical applications. By combining CNNs with
For the diagnosis and treatment of diseases, including K-Means clustering, brain tumors in MRI scans should be
cancer, medical imaging is crucial. One of the most deadly identified more quickly and accurately, which should improve
forms of cancer, brain tumors can damage the central nervous patient outcomes by enabling an early diagnosis. Moreover,
system and increase morbidity and death. Brain tumors can the technique’s effective CPU-based methodology guarantees
often be seen via magnetic resonance imaging (MRI), which its applicability in diverse medical contexts, including
creates finely detailed pictures of the structure of the brain. those with restricted access to sophisticated computational
However, it takes a lot of time, work, and is prone to human resources.
error to manually identify and segment tumors from MRI
images. II. R ELATED W ORK

Accurate and efficient segmentation and detection of brain [1]Color based segmentation methods are mostly used in
tumors in MRI images is essential for effective treatment study of brain tumor but in this paper Threshold-based OTSU
planning. Radiologists use different manual methods that segmentation was used. The experimental results showed that
require a lot of labor, while automated approaches can be faster this method of OTSU segmentation is better than the con-
and more dependable. But current systems frequently fail to ventional way of using color segmentation and gray scaling.
strike a compromise between great efficiency and precision. This paper provided a minimum of 87 percent accuracy on
In order to meet the demand for an effective automated multiple datasets. The method performed better than existing
system for brain tumor segmentation and identification, this approaches in segmenting the tumor region from the rest of
study makes use of K-Means clustering for preliminary the brain.
segmentation and Convolutional Neural Networks (CNNs) for [2] This paper introduces a method combining Artificial
accurate detection. Neural Networks and Fuzzy K-means for brain tumor
segmentation from MRI images. It involves four stages: noise
Numerous investigations have looked into ways to automate removal, feature extraction, classification, and segmentation,
the segmentation and identification of brain tumors. Although achieving high accuracy, sensitivity, and specificity on the
K-Means clustering is well-liked for its ease of use and BRATS dataset. The proposed method improves overall
efficiency in picture segmentation, it lacks the accuracy accuracy by 8 percent compared to K-Nearest Neighbor
required for clinical use. On the other hand, CNNs’ techniques.
capacity to recognize complex patterns has allowed them to
demonstrate considerable promise in picture categorization [3]This paper presents a robust brain tumor segmentation
tasks. Although brain cancers have been identified using method using local contrast enhancement with OTSU and K-
CNNs, it is still difficult to strike a compromise between means clustering in different transform domains. The approach
high accuracy and computational efficiency, particularly when enhances performance with adaptive histogram equalization
dealing with constrained CPU resources. and is evaluated using multiple quality metrics, achieving
high precision and reliability. It is effective for both 2D and
3D images, demonstrating independence from specific input outperforming existing techniques in the literature. The authors
datasets. validate their approach on the BRATS dataset, highlighting its
[4] This paper proposes a method for brain tumor iden- robustness and reliability.
tification using MRI image segmentation, comprising pre-
III. M ETHODOLOGY
processing, feature extraction, feature selection, classification,
and segmentation stages. Improved Gabor Wavelet Transform A. Dataset
(IGWT) and the Oppositional Fruit Fly Algorithm (OFFA) The ”Brain MRI Images for Brain Tumour Detection,”
enhance feature processing, while a support vector machine which was assembled by Navoneel Chakrabarty, is the dataset
(SVM) classifier and rough K-means algorithm are used that was used in this investigation. There are two classes of
for classification and segmentation. The methodology shows 253 brain MRI images in it: normal and pathological. Each
improved performance in sensitivity, specificity, and accuracy image has a resolution of 630 by 630 pixels and is in the
compared to existing techniques. JPEG format. This dataset is a useful resource for creating and
[5] This study presents a computer-aided approach for assessing brain tumour detection and segmentation algorithms.
brain tumor segmentation using a combination of convolu- The meticulously labelled photos provide a strong basis for
tional neural networks (CNN) and multiple kernel K-means deep learning model training and validation, making it possible
clustering (MKKMC). CNN classifies MR images as normal to distinguish between regions of aberrant tumour growth and
or abnormal, while MKKMC segments the tumor in abnormal normal brain tissue. A thorough approach to model training
images. Experimental results indicate that the proposed CNN- is ensured by the inclusion of both normal and abnormal in-
MKKMC method achieves superior accuracy, sensitivity, and stances, which advances the creation of trustworthy diagnostic
specificity with reduced time cost compared to existing meth- instruments for the identification of brain tumours.
ods.
[6] This paper presents a method for detecting and classify-
ing brain tumors using MRI images, involving pre-processing,
skull stripping, and tumor segmentation. The approach em-
ploys CNN with AlexNet and GooLeNet architectures for B. Pre-processing
classification, utilizing transfer learning to address overfitting
issues. Performance is evaluated using precision, recall, F- Preprocessing is a method for actions with images at the
measure, and accuracy metrics, demonstrating the effective- lowest level of abstraction. In this module, the image is im-
ness of the proposed method. proved in order to remove any kind of unwanted distortion and
[7] This paper presents a method for automatic brain tumor enhance signal features required for further processing.Any
segmentation in MRI images using a convolutional neural net- kind of unwanted noise is removed from the image to achieve
work on the BraTS dataset. The approach accurately predicts a perfect image.
tumor regions and dimensions in 3D imaging, achieving a Image Filtering and Enhancement:
mean prediction accuracy of 91.718 percent , with high IoU • Gaussian Filter:It is applied to the image to reduce

and BF scores. The results demonstrate significant similarity noise and smoothen the image. This step is essential
between ground truth and predicted labels, making it effective as it helps in enhancing the overall image quality by
for accurate brain tumor diagnosis. [8] This paper presents attenuating high-frequency components, which often rep-
a hybrid approach for brain tumor segmentation using fuzzy resent noise.The Gaussian filter is a linear filter that
clustering and deep learning. The proposed method combines uses a Gaussian function to weigh the pixel values. The
the advantages of fuzzy C-means clustering and convolutional Gaussian function ensures that the weights decrease with
neural networks (CNNs) to enhance segmentation accuracy. increasing distance from the center of the filter.
Experimental results on the BRATS dataset demonstrate the Formula: The Gaussian function in 2D is defined as:
method’s effectiveness in accurately segmenting brain tumors 1 − x2 +y2 2
G(x, y) = e 2σ
with improved performance metrics. [9] This study intro- 2πσ 2
duces a novel deep learning-based framework for brain tumor where x and y are the distances from the center of the
segmentation using MRI images. The framework employs a kernel, and σ is the standard deviation of the Gaussian
modified U-Net architecture with attention mechanisms to distribution. The size of the kernel is typically (2k +
focus on relevant tumor regions. The method is validated 1) × (2k + 1), where k is chosen based on the desired
on the BRATS dataset, showing superior performance in smoothing level.
terms of Dice similarity coefficient and segmentation accu- Implementation: In our approach, a Gaussian filter with
racy compared to traditional U-Net and other state-of-the-art a kernel size of 7×7 is applied to the image. This specific
approaches. [10] This paper proposes an advanced method for kernel size helps in achieving a balanced smoothing effect
brain tumor detection and segmentation using MRI images. without overly blurring important features.
The approach utilizes a combination of transfer learning with • Bilateral filtering:It is used to enhance the edges while
pre-trained VGG16 and a custom CNN architecture. The preserving the important features of the image. Un-
method achieves high accuracy, sensitivity, and specificity, like Gaussian filtering, which considers only the spatial
closeness, bilateral filtering also takes into account the analyzing the tumor’s characteristics and planning appropriate
intensity difference between pixels, making it effective treatment strategies. We employ K-means clustering combined
in preserving edges.The bilateral filter is a non-linear with Otsu thresholding to achieve precise and reliable segmen-
filter that computes the output pixel value as a weighted tation results.
average of nearby pixels. The weights are determined by K-means Clustering: K-means clustering is a powerful un-
both the spatial distance and the intensity difference. supervised learning algorithm that segments the image into
Formula: distinct regions based on pixel intensity
∥xi − x∥2
 
1 X 1) Clustering Setup:
Ifiltered (x) = I(xi ) · exp −
Wp 2σd2 • The grayscale MRI image is reshaped into a single
xi ∈S

|I(xi ) − I(x)|2
 column vector to prepare it for clustering. This
· exp − transformation converts the 2D pixel matrix into
2σr2
a 1D array, with each element representing the
where I is the input image, x is the current pixel, S is intensity value of a pixel.
the neighborhood of x, σd is the spatial standard devia- • K-means clustering is initialized with 3 clusters, as
tion, σr is the range standard deviation, and Wp is the it is hypothesized that this will effectively separate
normalization factor. Implementation: In our approach, the tumor from the other parts of the brain.
a bilateral filter with parameters σd = 9, σr = 75, and a
2) Cluster Assignment:
neighborhood size of 9 × 9 is applied. These parameters
• The K-means algorithm iteratively assigns each
are chosen to balance the trade-off between smoothing
and edge preservation. pixel to one of the 3 clusters based on its intensity
• Gray-scale conversion: Converting the enhanced image value, minimizing the variance within each cluster.
• Initial cluster centers are chosen randomly, and
from RGB to grayscale simplifies the image data by
reducing it to a single channel. This simplification is pixels are assigned to the nearest cluster center. The
essential for easier processing and analysis, particularly algorithm recalculates the cluster centers based on
in segmentation tasks where intensity variations are cru- the mean intensity values of the assigned pixels, re-
cial.The grayscale conversion involves transforming the peating this process until the assignments stabilize.
three color channels (Red, Green, Blue) into a single in- 3) Extracting Tumor Region:
tensity value. This is typically done by taking a weighted • After clustering, the labels (cluster assignments) are
sum of the three channels. reshaped back into the original image dimensions.
Formula: The standard formula for converting RGB to Each pixel in the label image is assigned a cluster
grayscale is: label (0, 1, or 2).
• The cluster with the maximum number of pixels,
Igray = 0.299 · R + 0.587 · G + 0.114 · B
typically representing the white region in the MRI,
where R, G, and B are the red, green, and blue channel is assumed to correspond to the tumor. Pixels be-
values, respectively. longing to this cluster are set to 255 (white), while
pixels in the other clusters are set to 0 (black),
creating a binary mask.The binary mask highlights
the tumor region, distinguishing it from the rest of
the image.

Fig. 1. Pre-processing

Implementation: In our approach, the enhanced RGB


image is converted to grayscale using the above formula.
This conversion highlights the intensity variations, which
are essential for effective segmentation using techniques
like K-Means clustering.
C. Segmentation D. Otsu Thresholding for Enhanced Accuracy
The segmentation process aims to isolate the tumor from the Otsu thresholding is employed to refine the segmentation
rest of the MRI image. Accurate segmentation is crucial for results obtained from K-means clustering. It is an adaptive
thresholding technique that automatically determines the op- • The activation function used is ReLU (Rectified
timal threshold value for separating the foreground (tumor) Linear Unit).
from the background. • The layer applies convolution operations to extract
1) Adaptive Thresholding: features from the input image.
• Otsu’s method calculates the threshold that mini- 3) First MaxPooling Layer:
mizes the intra-class variance, effectively separat- • A max-pooling operation with a pool size of 2x2 is
ing the two classes (tumor and non-tumor) in the applied to reduce the spatial dimensions and retain
grayscale image. the most important features.
• This method is particularly useful for images with
4) Second Convolutional Layer:
bimodal intensity distributions, where the tumor and
background have distinct intensity peaks. • This layer consists of 64 filters, each of size 3x3.
2) Combining Techniques: • The activation function used is ReLU.This layer
further extracts more complex features from the
• The binary mask generated from K-means clustering
image.
is refined using Otsu thresholding to ensure accurate
separation of the tumor from the background. 5) Second MaxPooling Layer:
• Pixels with intensity values above the Otsu threshold • Similar to the first max-pooling layer, a 2x2 max-
are set to 255 (white), while those below are set to 0 pooling operation is applied to further reduce the
(black), further enhancing the tumor segmentation. spatial dimensions.
E. Feature Extraction 6) Flatten Layer:
After achieving the segmented image, the tumor region is • This layer flattens the 2D output from the previous
identified and extracted by comparing the original image with layer into a 1D vector to prepare it for the fully
the segmented image. The process involves collapsing both connected layers.
images to isolate the tumor area. The K-means clustering 7) First Dense (Fully Connected) Layer:
results help in accurately segmenting the tumor from the
• This layer consists of 128 units.
rest of the brain. This extraction ensures that the differences
• The activation function used is ReLU.
between the original and segmented images are highlighted,
• It enables the network to learn complex represen-
allowing for a clear separation of the tumor. The final extracted
tations from the features extracted by the convolu-
region, which contains the tumor, is then ready for further
tional layers.
analysis or classification, ensuring precise feature extraction
for subsequent processing steps.
Listing 1. CNN Architecture
classifier = Sequential()
classifier.add(Conv2D(32, (3, 3), input_shape
=(64, 64, 3), activation=’relu’))
classifier.add(MaxPooling2D(pool_size=(2, 2)))
classifier.add(Conv2D(64, (3, 3), activation=’
relu’))
classifier.add(MaxPooling2D(pool_size=(2, 2)))
classifier.add(Flatten())
classifier.add(Dense(units=128, activation=’
relu’))
classifier.add(Dense(units=1, activation=’
sigmoid’))
classifier.compile(optimizer=’adam’, loss=’
binary_crossentropy’, metrics=[’accuracy’])

IV. T RAINING 8) Output Dense Layer:


Convolutional Neural Network (CNN) Architecture The • The final dense layer consists of 1 unit.
Convolutional Neural Network (CNN) architecture utilized in • The activation function used is Sigmoid.
this study is designed for binary classification of MRI brain • This layer outputs a probability value indicating the
images into normal and abnormal categories. The architecture classification of the input image as either normal or
is constructed as follows: abnormal.
1) Input Layer: 9) Compilation:
• The input layer receives images of dimensions
• The network is compiled using the Adam optimizer.
64x64 pixels with 3 color channels (RGB). • The loss function used is binary cross-entropy, suit-
2) First Convolutional Layer: able for binary classification tasks.
• This layer consists of 32 filters, each of size 3x3. • The performance metric monitored is accuracy.
V. R ESULTS as it enables tumor identification from MRI scans using low-
Accuracy shows results above 90 which is suitable ac- cost hardware and minimal computation time.. If a more
curacy.The following graphs will show accuracies between precise dataset is used for training, then the computation power
training and validation accuracies. required can be reduced and achieve even more accuracy. If
a more precise dataset is used for training, then the compu-
tation power required can be reduced and achieve even more
accuracy
R EFERENCES
[1] T. S. Sazzad, K. T. Ahmmed, M. U. Hoque, and M. Rahman, “Develop-
ment of automated brain tumor identification using mri images,” in 2019
International conference on electrical, computer and communication
engineering (ECCE). IEEE, 2019, pp. 1–4.
[2] A. R. Khan, S. Khan, M. Harouni, R. Abbasi, S. Iqbal, and Z. Mehmood,
“Brain tumor segmentation using k-means clustering and deep learning
with synthetic data augmentation for classification,” Microscopy Re-
search and Technique, vol. 84, no. 7, pp. 1389–1399, 2021.
[3] O. S. Faragallah, H. M. El-Hoseny, and H. S. El-sayed, “Efficient brain
tumor segmentation using otsu and k-means clustering in homomorphic
transform,” Biomedical Signal Processing and Control, vol. 84, p.
104712, 2023.
[4] A. Biswas and M. S. Islam, “Brain tumor types classification using
k-means clustering and ann approach,” in 2021 2nd International
Conference on Robotics, Electrical and Signal Processing Techniques
(ICREST). IEEE, 2021, pp. 654–658.
[5] B. Ragupathy and M. Karunakaran, “A deep learning model integrating
convolution neural network and multiple kernel k means clustering for
segmenting brain tumor in magnetic resonance images,” International
Journal of Imaging Systems and Technology, vol. 31, no. 1, pp. 118–
• F1-Score: This metric balances precision and recall, 127, 2021.
[6] S. M. Kulkarni and G. Sundari, “A framework for brain tumor segmen-
providing a single measure of a model’s accuracy by tation and classification using deep learning algorithm,” International
considering both false positives and false negatives. Journal of Advanced Computer Science and Applications, vol. 11, no. 8,
• Precision: This metric indicates the proportion of true 2020.
[7] G. Karayegen and M. F. Aksahin, “Brain tumor prediction on mr images
positive results among all positive predictions made by with semantic segmentation by using deep learning network and 3d
the model. imaging of tumor region,” Biomedical Signal Processing and Control,
• Recall: This metric measures the proportion of true vol. 66, p. 102458, 2021.
[8] S. Reza, M. Islam, and H. Sazzad, “Brain tumor segmentation using hy-
positive results among all actual positive instances in the brid approaches: A combination of fuzzy clustering and deep learning,”
dataset. International Journal of Advanced Computer Science and Applications,
• MCC (Matthews Correlation Coefficient:) This metric vol. 11, no. 2, pp. 124–132, 2020.
[9] I. Hossain, M. Ali, and R. Khan, “Deep learning-based brain tumor
provides a balanced measure of the quality of binary segmentation using mri images: A modified u-net architecture with
classifications, even if the classes are of different sizes, attention mechanisms,” IEEE Access, vol. 9, pp. 123 456–123 465, 2021.
by considering true and false positives and negatives. [10] M. Sharif, M. Hussain, and Z. Iqbal, “Brain tumor detection and
segmentation using transfer learning and custom cnn,” Neurocomputing,
vol. 439, pp. 85–95, 2021.
Metric Training Set Testing Set
F1-Score 0.9223 0.8434
Precision 0.80 0.78
Recall 0.93 0.83
MCC 0.879 0.643
TABLE I
P ERFORMANCE M ETRICS FOR THE M ODEL

A. Conclusion
The tumor was extracted properly from the images and
trained upon them.This research presents findings on various
brain tumor classification techniques suitable for brain tumor
detection, along with an image segmentation algorithm for au-
tomated detection and classification. The optimal results were
achieved with minimal computational effort, showcasing the
efficiency of the proposed K-means algorithm in identifying
and classifying brain tumors. This approach is advantageous

You might also like