Project T
Project T
Declaration ii
Acknowledgement iii
Abstract iv
List Of Figures v
Chapter-1 Introduction 1
1.1 Brain Anatomy
1.2 Motivation For The Work
1.3 Problem Statement
1.4 Scope
Chapter-3 Methodology 6
4.3 Pre-Processing
4.4 Thresholding
Output 19
Result 21
References 24
CERT
IFICA
TE
\
iv
ABSTRACT
The human brain, being the central command center of the body, is vulnerable to abnormal cell growth
that can lead to the development of brain tumors, which may progress into brain cancer. In the
healthcare domain, Computer Vision plays a crucial role, minimizing human biases and delivering
accurate diagnostic results. Imaging methods like CT scans, X-rays, and MRI scans, particularly
magnetic resonance imaging (MRI), are dependable and safe techniques. MRI, due to its high
resolution, is adept at detecting even the smallest irregularities within the brain.
This article explores various techniques for detecting brain tumors using brain MRI. The research starts
with preprocessing steps that involve using the Gaussian filter to remove inherent image noise in MR
images. Following this, binary thresholding and Convolutional Neural Network (CNN) segmentation
techniques are employed to ensure precise identification of tumor areas. Different datasets are used for
training, testing, and validation purposes.
By employing machine learning models, the goal is to predict the presence or absence of brain tumors
in subjects. The resulting predictions will be thoroughly assessed using various performance metrics
such as accuracy, sensitivity, and specificity. The objective is to demonstrate the superior performance
of the proposed methodology compared to existing approaches in the field.
v
LIST OF FIGURE
vi
CHAPTER 1
INTRODUCTION
The human brain, a complex and mysterious organ, has been a focal point in numerous medical
investigations due to its association with intricate disorders. Among these, brain tumors and
Alzheimer’s Disease stand out as profoundly impactful, affecting not only individuals but also their
surrounding families and communities.
A brain tumor denotes an irregular cell growth in the brain or central spine, disrupting normal brain
function. Medical professionals classify tumors based on their origin and whether they are malignant or
benign. Conversely, Alzheimer’s Disease progresses gradually, leading to the degeneration and death
of brain cells, becoming a primary cause of dementia—a gradual decline in cognitive, behavioral, and
social abilities hindering independent functioning.
Brain tumors encompass any mass formed by abnormal and unregulated cell growth in the brain. These
tumors are categorized based on their origin, location, tumor area, and tissue characteristics. Various
types of brain tumors include:
Magnetic resonance imaging (MRI) and computed tomography (CT) scans are the primary tests for
detecting and locating tumors, aiding in treatment decisions. These scans remain widely used due to
their convenience and ability to provide high-definition images of pathological tissues. Currently,
several treatment options are available for tumors, including surgery, radiation therapy, and
chemotherapy.
7
1.2 Motivation For The Work
Accurate identification of brain abnormalities is crucial for treatment procedures, aiming to reduce
diagnostic errors. This precision is often facilitated by computer-aided diagnosis (CAD) systems. The
primary objective of computer vision is to generate reliable outputs, aiding medical professionals in
image interpretation and reducing reading time. While these advancements improve diagnosis
reliability and accuracy, segmenting a brain tumor and its surrounding area from an MR image remains
challenging. The presence of tumors in specific brain regions without distinct picture intensities further
complicates automated tumor detection and segmentation.
In the face of these challenges, modern medicine stands poised at the intersection of technological
progress and the burgeoning field of artificial intelligence. Harnessing advanced machine learning
algorithms, the goal is to transform brain tumor identification through MRI scans. This ambitious
endeavor seeks not only to improve accuracy but also to enhance the speed and scalability of the
detection process.
By employing innovative techniques in image preprocessing, feature extraction, and classification, the
ultimate aim is to develop a robust and reliable diagnostic tool. Such a tool has the potential to
significantly assist healthcare professionals, offering a more efficient, accessible, and cost-effective
means of early detection and diagnosis.
8
1.3 Problem Statement
Our research focuses on automating the detection and classification of brain tumors. Typically, brain
anatomy is assessed using MRI or CT scans. The objective of our study is to identify tumors in brain
MR images, primarily to aid clinical diagnosis. We aim to develop an algorithm that ensures reliable
tumor detection by integrating multiple procedures, thereby offering a foolproof method for detecting
tumors in MR brain images. The techniques employed include filtering, erosion, dilation, thresholding,
and tumor outlining, such as edge detection.
The core of this project lies in extracting and simplifying the representation of tumors from MR brain
images, making it comprehensible to a broader audience. Our goal is to present valuable information in
an accessible format, particularly for medical personnel treating patients. We aim to establish an
algorithm capable of producing an extracted image of the tumor from the MR brain image. This
resultant image will provide details such as tumor size, dimensions, and position, while its boundary
offers additional insights into the tumor, aiding decision-making in various scenarios. Ultimately, we
employ Convolutional Neural Network to determine the presence of tumors in the given MR brain
image.
1.4 Scope
Our objective is to create an automated system for improving, segmenting, and categorizing
brain tumors. This system is intended for use by neurosurgeons and healthcare professionals. It
integrates image processing, pattern analysis, and computer vision techniques, aiming to enhance
the sensitivity, specificity, and effectiveness of brain tumor detection. In medical imaging
endeavors, the key aim is to extract valuable and precise data from images with minimal errors.
By carefully combining and adjusting the phases, we can develop auxiliary tools that aid in early
diagnosis or tracking tumor identification and locations..
9
CHAPTER 2
LITERATURE REVIEW
Elchouemi, A., Singh, A.K., Prasad, P.W.C., Alsadoon, A., and Devkota, B. (2018). Mathematical
Morphological Reconstruction for Brain Tumour Early Stage Identification. Computer Science
Procedia.
Segmentation and Classification of MRI Brain Tumour," P.S. Mukambika, K. Uma Rani,
International Research Journal of Engineering and Technology (IRJET).
Preprocessing, Segmentation, Feature Extraction, and Classification are the four modules that make up
the MRI brain tumour detection and classification system. Preprocessing is where the skull removal is
done. The preprocessed image is then fed into the K-means algorithm and the Level Set method, two
segmentation methods, to extract the tumour region. With DWT and GLCM, statistical textural traits
are obtained. Lastly, SVM is used to categorise the acquired features into tumour types that are benig
10
Varuna Shree, N., and Kumar, T.N.R.: Probabilistic neural network and DWT feature
extraction for brain tumour identification and classification in MRI images.
The suggested tumour detection technique makes use of Discrete Wavelet Transforms (DWT) in three
stages: filtering to improve images, extracting features from gray-level co-incidence matrices (GLCM),
and segmenting tumour locations using DWT. To remove post-segmentation noise, morphological
filtering is used in conjunction with denoising. For abnormality detection, a PNN classifier trained on a
variety of datasets is employed, and it achieves good accuracy in identifying tumour locations in MR
brain images.
Javeria Amin, Mussarat Yasmin, and Muhammad Sharif (2020). An innovative method for MRI-
based brain tumour identification and categorization
The automated approach for early brain tumour identification in MRI scans shown in this research is
essential for prompt intervention since brain tumours develop quickly. For every candidate lesion, a
feature set comprising shape, texture, and intensity is chosen using a variety of segmentation
algorithms. The suggested method, which uses Support Vector Machine (SVM) classification,
outperforms existing methods in terms of processing time and precision, with an average accuracy of
97.1%, 0.98 area under the curve, 91.9% sensitivity, and 98.0% specificity across three benchmark
datasets (Harvard, RIDER, and Local).
Mohsena Ashraf and Fairuz Shadmani Shishir, MD Faisal Muhammad Shah and Abdullah Al
Nasim (2018). via deep convolutional neural networks to detect brain tumours via big data
analysis
This study presents a seven-layer Deep Neural Network (DNN) architecture for segmentation and
classification in the context of MRI images as a tool for brain tumour detection. To achieve accurate
11
segmentation, input MR images are separated into patches, and DNN assigns labels based on values of
the centre pixels. The model's performance is validated through extensive trials on eight benchmark
datasets, including BRATS and ISLES, utilising measures like FPR, TPR, JSI, ACC, SE, and SP.
12
Chapter-3
Methodology
By applying pertinent filters to an image, a ConvNet may effectively capture the spatial and
temporal dependencies present in the image. Because fewer parameters are used in the design
and weights can be reused, it fits the picture dataset more accurately. Stated differently, the
network can be trained to comprehend the image's complexity more effectively. ConvNet's job is
to simplify the images into a format that is simpler to process while preserving the elements that
are essential for producing an accurate forecast.
Preprocessing, segmentation, feature extraction and reduction, and, in the very end, a very
machine learning algorithm for classification are the steps involved in tumour identification.
4.1 Dataset
MRI stands for magnetic resonance imaging. This medical imaging method creates images of the
body's structure and physiological functions in both healthy and diseased states for use in radiology.
An MRI picture contains data such as the patient's name, the physician's name, the date and time, and
so on. The amplitude at each given position (x, y, z) is referred to as the image's intensity level. This
image is defined as a three-dimensional function, f(x, y, z), where x, y, and z are spatial coordinates.
You have downloaded the Brain MRI image dataset from Kaggle.The 7023 MRI pictures in the MRI
dataset are divided into four classes: pituitary, meningioma, glioma, and no tumour.
4.3 Pre-processing
The first and most important stage in raising the quality of the brain MRI image is pre-processing. We
employed a cropping technique to determine the extreme top, bottom, left, and right points of the brain
in order to crop the area of the image that only contains the brain.
Reducing impulsive sounds and shrinking images are crucial pre-processing processes.
14
4.3.1 Using the CvtColor function, we first eliminated all colour from the image in order to convert it
to grayscale. Processing speed is increased when a 3D image is converted to a 2D image.
Our MRI dataset included Gaussian noise, which is a result of random fluctuations in the signal and is
represented by random values added to an image with a probability density function (pdf) that follows
a normal distribution.
Gaussian blur is used to smooth out the image by reducing noise. Both the diagnostic and the
classification accuracy rate are enhanced by this. One method of applying a low-pass filter to a scikit-
image is the Gaussian blur. It is frequently applied to images to eliminate Gaussian noise, or random
noise.
Two essential procedures in image processing are dilatation and erosion, which are used to process
images morphologically. These techniques are frequently combined to improve an image's
characteristics or get rid of noise. Morphological procedures in image processing are carried out via
erosion and dilation. These procedures are very helpful in applications like image segmentation, feature
extraction, and noise reduction because they allow you to change the sizes and shapes of objects in an
image.
15
It can be applied to eliminate minor white noise, separate two related items, and more.
2. Dilation:
Dilation comes after erosion in situations such as noise removal. Because erosion reduces our object's
size while simultaneously eliminating white noise. Thus, we enlarge it. They won't return because the
noise is gone, but our object area grows.It can also be used to repair damaged object pieces.
Thresholding is a kind of image segmentation in which the pixels are altered to facilitate image
analysis. Through thresholding, we can transform a colour or grayscale image into a binary—that is,
just black and white—image. Most often, thresholding is used to isolate regions of interest within a
picture while disregarding the portions we are not interested in.
In our code, we make use of the THRESH_BINARY type.
We find contours in the thresholded image and identifies the largest contour, assumed to outline
the brain region and determine the extreme points (left, right, top, bottom) of the largest contour to
define the boundary of the brain region.
4.5 Loading the data: This step involves accessing the image dataset, which may contain images of
various sizes and dimensions.
16
Cropping the Brain Region: The crop_brain_contour function is employed to isolate the
specific area of the image that represents the brain. This process removes any extraneous
or non-relevant parts, focusing solely on the brain region for analysis.
Resizing the Image: As different images might come in varying sizes, it's essential to
standardize the dimensions for consistency. Resizing the images to a common shape
(240x240 pixels in this case) ensures uniformity across the dataset. This step also
includes adjusting the number of color channels to match the desired format (e.g., RGB -
3 channels).
These procedures, which include loading the data, normalising pixel values, standardising image
sizes, and cropping the image to isolate the brain region, make the image dataset uniform and
prepared to be fed into a neural network for additional processing, like training for tasks like
brain tumour detection or classification. By ensuring consistency and optimal compatibility with
the neural network architecture, this preprocessing makes learning and analysis more efficient..
17
Chapter-5
CNN MODEL
These procedures, which include loading the data, normalising pixel values, standardising image sizes,
and cropping the image to isolate the brain region, make the image dataset uniform and prepared to be
fed into a neural network for additional processing, like training for tasks like brain tumour detection or
classification. By ensuring consistency and optimal compatibility with the neural network architecture,
this preprocessing makes learning and analysis more efficient.
For this step we need to import Keras and other packages that we’re going to use in building
the CNN.
18
5.1 Understanding the Architecture
The shape of each input x (picture), which is fed into the neural network, is (240, 240, 3). It displays
the input images in three colour channels (Red, Green, and Blue) with a width and height of 240
pixels.It also passes through the subsequent layers:
1. A pool size of (2, 2) for a layer of zero padding:In order to preserve spatial dimensions, this adds
zeros to the input tensor. By doing this, the spatial information around the edges of the input image is
preserved for the convolutional layer that comes next.
2. A 32-filter convolutional layer with a stride of 1: 3 and a filter size of (7, 7).With each filter having a
7x7 receptive field, 32 filters are used to apply a convolutional operation. The filters travel one pixel at
a time thanks to the stride of 1.
4. A batch normalisation layer to expedite calculation by normalising pixel values:
In the batch dimension, this normalises the activations of the preceding convolutional layer. This
promotes faster convergence during training and increases stability during the optimisation process.
5. A ReLU activation layer: A rectified linear unit (ReLU) is an activation function that addresses the
vanishing gradients problem and adds the property of nonlinearity to a deep learning model.
6. A Max Pooling layer with f=4 and s=4: It uses max pooling operations with a pool size of 4x4 to
minimise the spatial dimensions of the data. By lowering computing complexity, this downsampling
aids in capturing the most crucial features.
7. An identical Max Pooling layer with f=4 and s=4:downsamples the data for more abstraction by
further reducing the geographical dimensions while preserving the key characteristics.
8. A flatten layer: This flattens the three-dimensional output from the last convolutional layer into a
one-dimensional vector. It does this by flattening the three-dimensional matrix into a one-dimensional
vector. In doing so, the data is ready to be fed into a fully linked layer.
9. Because this is a binary classification problem, a dense (output unit) completely linked layer with
one neuron that exhibits sigmoid activation: a single, completely linked layer of neurons with sigmoid
activation function. This functions as the binary classification's output layer, where
19
the output is squashed by the sigmoid function between 0 and 1, giving the likelihood of
falling into the positive class (tumour or no tumour).
Convolutional, activation, pooling, and fully connected layers are included in this design, which
is typical of CNNs used for image classification applications. After learning hierarchical features
from the input images, the network reduces spatial dimensions gradually and extracts meaningful
representations. Finally, it decides whether to classify the images as binary based on whether or
not brain tumours are present in them.
1. Recording the start time: start_time = time.time(): this function marks the beginning of the model
training phase by capturing the current time.
2. Training Models:
model.fit(): Starts the neural network model's training procedure. Training data (input features) and
matching labels are stored as x_train and y_train.
batch_size=32: Specifies how many samples are used in each gradient update throughout training.
After each set of 32 training examples, the model will update its weights in this instance.
20
1. validation_data=(X_val, y_val): During training, the model's performance is assessed by setting
aside a validation dataset (X_val) and the labels that correspond to it (y_val). This aids in tracking
whether the model is overfitting or effectively generalising to new data.
2. callbacks=[tensorboard, checkpoint]: Callbacks are incorporated into the training process. During
training, callback functions are invoked at predetermined intervals. Examples of callback functions
are TensorBoard for visualisation and ModelCheckpoint for model weight saving.
end_time = time.time(): Captures the current time after the model training completes.
execution_time = (end_time - start_time): Calculates the duration of the training by subtracting
the starting time from the ending time.
print(f"Elapsed time: {hms_string(execution_time)}"): Displays the elapsed time in a human-
readable format using the hms_string() function (not explicitly provided in the code snippet).
We demonstrate the training process of a neural network model using the specified training data,
batch size, number of epochs, and validation data. It measures the time taken for the model to
complete the training process and prints out the elapsed time once the training finishes. The
model's performance during training, including accuracy and loss metrics, is also monitored
using the validation data provided.
21
Chapter-6
SOFTWARE REQUIREMENTS
6.1 Python:
The 1991 release of Python, a high-level, general-purpose, interpreted programming language designed
by Guido Van Rossum, highlighted code readability by the noticeable use of substantial whitespace. Its
object-oriented methodology and language elements are designed to assist programmers in writing
logical, understandable code for both small and large-scale projects. Python has garbage collection and
dynamic typing. It is compatible with several programming paradigms, such as functional, object-
oriented, and procedural programming.
6.2 Packages
PIP:
Installing and managing Python software packages is done through this package management system.
NumPy:
A general-purpose array processing package is called NumPy. Together with tools for managing these
arrays, it offers a multidimensional array object with excellent performance. This is the core Python
module for scientific computing. It has a number of characteristics, some of which are significant:
• An effective N-dimensional array item
• Practical Fourier transform, random number, and linear algebra features Pandas:
An open-source deep learning package called TensorFlow is frequently used for creating and refining
neural network mode.
22
● Used Modules:
Access different layers for building neural network designs with tf.keras.layers.
tf.keras.models:
Scikit-learn, or sklearn,
● Goal: scikit-learn is a potent machine learning package that offers effective and user-friendly tools
for modelling and data analysis.
● Used Modules:
train_test_split: Divides datasets into test and train sets in order to assess the model.
Keras:
OpenCV:
A library of programming functions called OpenCV (Open source computer vision) is primarily
focused on real-time computer vision. It was first created by Intel and later sponsored by Willow
23
Garage and Itseez, which Intel eventually purchased. Under the terms of the open source BSD licence,
the library is cross-platform and free to use. According to a 17-defined list of supported layers,
OpenCV supports certain models from deep learning frameworks such as TensorFlow, Torch, PyTorch
(after converting to an ONNX model), and Caffe. It advocates for Open Vision Capsules, a format that
is portable and interoperable with all other formats.
Modules Employed:
cv2.imread(): Opens a file and reads an image.
● cv2.cvtColor(): Transforms an image between different colour spaces, such as BGR and grayscale.
cv2.GaussianBlur(): Reduces noise in a picture by applying a Gaussian blur.
cv2.threshold(): Generates a binary image by thresholding.
cv2.erode() and cv2.dilate(): These functions apply morphological effects to pictures, such as erosion
and dilation.
cv2.resize(): Adjusts an image's dimensions to a given value.
cv2.imread(): Opens a file and reads an image.
24
● BatchNormalization(): Enhances the model with batch normalisation.
●Activation(): Modifies a layer's output by applying an activation function.
● MaxPooling2D(): Enhances the model with a max-pooling layer.
The flatten() function flattens the input.
● Dense(): Enhances the model with a fully connected layer.
Model(): Constructs a Keras model. mutils, also known as imutils:
Imutils is a set of practical utilities designed to facilitate common image processing tasks.
The execution of several tasks linked to image processing and machine learning is made possible by
these packages and modules, which include functionality for data handling, charting, neural network
construction, image modification, and general-purpose computation.
25
26
OUTPUT
Accuracy Score:
Accuracy is a common metric that represents the overall correctness of a classification model. It
is calculated as the ratio of correctly predicted instances to the total instances. In our case, we
have an accuracy of 75%, it means that the model correctly classified 75% of the brain tumor
images in the test set.
F1 Score:
The F1 score is the harmonic mean of precision and recall. Precision is the ratio of correctly
predicted positive observations to the total predicted positives, while recall is the ratio of
correctly predicted positive observations to all the actual positives. The F1 score balances
precision and recall, providing a single score that considers both false positives and false
negatives.
27
Our F1 score is 74%, it means that the model achieved a good balance between precision and
recall. This is important in medical applications like brain tumor detection, where both false
positives (misclassifying a healthy brain as having a tumor) and false negatives (missing an
actual tumor) are crucial considerations.
28
RESULT
Qualitative analysis was conducted to assess the visual interpretability of the brain tumor
detection model. A subset of images from the dataset was carefully selected to represent various
scenarios, including both correct and incorrect predictions. The goal was to explore how well the
model generalizes to diverse cases and to identify instances where the model might exhibit
challenges.
Several instances showcased the model's capability to accurately identify brain tumor presence.
These images demonstrated the model's effectiveness in recognizing distinct tumor patterns, such
as irregular shapes and enhanced contrast regions.
Misclassified Images:
Despite its overall accuracy, the model encountered challenges in certain scenarios.
Misclassifications were observed in images where tumor boundaries were less defined, or where
non-tumor regions exhibited characteristics that could be mistaken for tumors.
Boundary Cases:
Boundary cases, where the model's predictions were particularly uncertain, were examined.
These cases often involved images with ambiguous features or tumors located near anatomical
structures that could confound the model. Figure 4 displays examples of such boundary cases.
The qualitative analysis complements the quantitative metrics, providing a deeper understanding
of the model's behavior. While the model demonstrates high accuracy, the examination of
misclassified and boundary cases highlights areas for potential improvement. The findings from
the qualitative analysis will be further discussed in the subsequent sections, exploring avenues
for model enhancement and addressing the challenges identified in the visual assessment.
29
Challenges In Tumor Classification
The identification of tumor is a very challenging task. The location, shape and the structure of
tumor varies significantly from patient to patient which makes the segmentation a very
challenging task. In the figure shown below, we have shown some images of the same brain slice
from different patients, which clearly reflect the variation of the tumor. We can clearly see that
the location of the tumor is different in all the 8 images/patients shown below. To make it worse,
the shape and the intra-tumoral structure is also different for all the eight patients/images. In fact,
there can be more than one region of the tumor as can be seen from the images below. This
indeed reflects the complexity of automatic segmentation.
30
CONCLUSION & FUTURE SCOPE
Conclusion
We proposed a computerized method for the segmentation and identification of a brain tumor
using the Convolution Neural Network. The input MR images are read from the local device
using the file path and converted into grayscale images. These images are pre-processed using an
adaptive gaussian filtering technique for the elimination of noises that are present inside the
original image. The binary thresholding is applied to the denoised image, and Convolution
Neural Network segmentation is applied, which helps in figuring out the tumor region in the MR
images. The proposed model had obtained an accuracy of around 75% and yields promising
results without any errors and much less computational time.
Future Scope
It is observed on extermination that the proposed approach needs a vast training set for better
accurate results; in the field of medical image processing, the gathering of medical data is a
tedious job, and, in few cases, the datasets might not be available. In all such cases, the proposed
algorithm must be robust enough for accurate recognition of tumor regions from MR Images.
The proposed approach can be further improvised through in cooperating weakly trained
algorithms that can identify the abnormalities with a minimum training data and also self-
learning algorithms would aid in enhancing the accuracy of the algorithm and reduce the
computational time.
31
REFERENCES
Devkota, B. & Alsadoon, Abeer & Prasad, P.W.C. & Singh, A.K. & Elchouemi, A.. (2018).
Image Segmentation for Early Stage Brain Tumor Detection using Mathematical Morphological
Reconstruction. Procedia Computer Science. 125. 115123. 10.1016/j.procs.2017.12.017.
K. Sudharani, T. C. Sarma and K. Satya Rasad, "Intelligent Brain Tumor lesion classification
and identification from MRI images using k-NN technique," 2015 International Conference on
Control, Instrumentation, Communication and Computational Technologies (ICCICCT),
Kumaracoil,2015,pp.777-780.DOI:10.1109/ICCICCT.2015.7475384
Kaur, Jaskirat & Agrawal, Sunil & Renu, Vig. (2012). A Comparative Analysis of Thresholding
and Edge Detection Segmentation Techniques. International Journal of Computer
Applications.vol. 39.pp. 29-34. 10.5120/4898-7432.
Li, Shutao, JT-Y. Kwok, IW-H. Tsang and Yaonan Wang. "Fusing images with different focuses
using support vector machines." IEEE Transactions on neural networks 15, no. 6 (2004):1555-
1561.
32
M. Kumar and K. K. Mehta, "A Texture based Tumor detection and automatic Segmentation
using Seeded Region Growing Method," International Journal of Computer Technology and
Applications, ISSN: 2229-6093, Vol. 2, Issue 4, PP. 855859 August 2011.
Mahmoud, Dalia & Mohamed, Eltaher. (2012). Brain Tumor Detection Using Artificial Neural
Networks. Journal of Science and Technology. 13. 31-39.
Marroquin J.L., Vemuri B.C., Botello S., Calderon F. (2002) An Accurate and Efficient Bayesian
Method for Automatic Segmentation of Brain MRI. In: Heyden A., Sparr G., Nielsen M.,
Johansen
P. (eds) Computer Vision — ECCV 2002. ECCV 2002.
33