0% found this document useful (0 votes)
88 views81 pages

AI-Based Early Detection of Brain Tumors

This document outlines a graduation project submitted by two students to partially fulfill their B.Sc. degree requirements in electrical and computer engineering. The project proposes developing a system for the early detection of brain cancer using artificial intelligence. It includes a literature review on existing brain tumor detection methods, an overview of hardware and software tools that could be used, and a proposed system design. The system would use a convolutional neural network trained on brain tumor images to recognize and classify tumors in new images. The document provides details on implementing and testing the system using a Raspberry Pi for hardware and Python libraries like OpenCV and TensorFlow for software.

Uploaded by

Mazozi safae
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)
88 views81 pages

AI-Based Early Detection of Brain Tumors

This document outlines a graduation project submitted by two students to partially fulfill their B.Sc. degree requirements in electrical and computer engineering. The project proposes developing a system for the early detection of brain cancer using artificial intelligence. It includes a literature review on existing brain tumor detection methods, an overview of hardware and software tools that could be used, and a proposed system design. The system would use a convolutional neural network trained on brain tumor images to recognize and classify tumors in new images. The document provides details on implementing and testing the system using a Raspberry Pi for hardware and Python libraries like OpenCV and TensorFlow for software.

Uploaded by

Mazozi safae
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/ 81

October University for Modern Science & Arts

Faculty of Engineering
Department of Electrical Communication and Electronics
Systems

Early Detection of Brain Cancer Based on


Artificial Intelligence

A Graduation Project
Submitted in Partial Fulfillment of B.Sc. Degree
Requirements in Electrical and Computer Engineering
Part II

Prepared By

Micheal Nabil Salama Zaki 134119


Saad Mohamed Saad Abofarw 133623

Supervised By
Dr. Mohamed Saeed

2022-2023
TABLE OF CONTENTS

Page
TABLE OF CONTENTS I
List of Tables III
List of Figures IV
List of Abbreviations VI
Acknowledgment VII
Abstract VIII
Chapter I 1
INTRODUCTION 1
1.1 Problem Definition 1
1.2 Applied System 2
1.3 Main Objectives 3
1.4 Methodology 4
1.5 Software 5
1.6 Report organization 5
Chapter II 6
Brain Cancer Detection Survey 6
2.1 Introduction 6
2.1.1 Research Challenges 6
2.1.2 Related Problems 8
2.1.3 Data Collection 8
2.1.4 Contribution of this survey 9
2.2 Deep Learning Based Brain Tumor Segmentation Methods 10
2.2.1 Convolutional Neural Network Based Methods 11
2.2.2 Recurrent Neural Network Based 15
2.2.3 Deep Generative Model Based 16
2.3 Object Detection Methods 18
2.3.1 Region-based Convolutional Neural Networks(R-CNN): 19
2.3.2 Faster R-CNN: 20
2.3.3 YOLO(You only Look Once): 21
2.3.4 Single Shot Detector(SSD): 22
Chapter III 24
Proposed Early Detection of Brain Cancer Using AI. 24

I
3.1 Block Diagram 24
3.2 Hardware Tools 25
3.2.1 Nvidia Jetson Xavier NX 25
3.2.2 Raspberry Pi 4 27
3.2.3 Google Coral Dev Board 29
3.2.4 Rock Pi N10 31
3.2.5 HiKey 970 33
3.3 Software Tools 34
3.3.1 Python 34
3.3.2 OpenCV 36
3.3.3 Tensor Flow 37
3.3.4 Py Torch 37
Chapter IV 39
System Design 39
4.1 Top Level Circuit 39
4.1.1 Image processor Module: 39
4.2 Algorithms 39
4.2.1 Training Algorithm 39
4.2.2 Detecting and Recognition Algorithm 41
4.3 Summary 42
Chapter V 44
Implementation and Testing 44
5.1 Hardware implementation 44
5.1.2 Problem encountered 44
5.2 Software implemented 44
5.2.1 Operating System on a Raspberry Pi 44
5.2.2 Brain Tumor Training 47
5.2.2 Brain Tumor Recognition 52
Chapter VI 62
COST ANALYSIS 62
Chapter VII 63
TIME PLAN 63
Chapter VIII 64
CONCLUSION AND FUTURE WORK 64
8.1 Conclusion 64
8.2 Future Work 65
II
List of Tables

Page
Table 2.1 Comparison of CNN Based Methods 15
Table 2.2: Comparison of RNN Based Methods 18
Table 2.3: Comparison of R-CNN Vs Fast R-CNN Vs Faster R-CNN 21
Table 6.1 Cost Analysis 62
Table 7.1 Time Plan 63

III
List of Figures

Page
Fig. 1.1: Detection of Brain Cancer Flow Char 4
Fig. 2.1: Challenges in segmenting brain glioma tumors, glioma tumor
exemplars, statistical information of the training set [11] 7
Fig. 2.2: Data Collection for Brain Tumours [18] 9
Fig. 2.3: A taxonomy of this survey for brain tumour segmentation [20] 10
Fig. 2.4: A sketch comparison brain tumor segmentation algorithms [21] 11
Fig. 2.5: Convolutional Neural Network [20] 11
Fig. 2.6: Fully Convolutional Neural Network Based [25] 12
Fig. 2.7: Fully Convolutional Neural Network Based [26] 14
Fig. 2.8: Recurrent Neural Network Based [27] 16
Fig. 2.9: Generative Adversarial Networks [30] 17
Fig. 2.10: Auto-Encoders [30] 17
Fig. 2.11: Object Detection example [21] 18
Fig. 2.12: R-CNN Architecture 20
Fig. 2.13: Faster R-CNN Architecture 20
Fig. 2.14: YOLO Architecture 22
Fig. 2.15: Accuracy vs speed chart 23
Fig. 2.16: YOLO vs SSD vs Faster-RCNN for various sizes 23
Fig. 3.1: Train and Testing block diagram 24
Fig. 3.2: Nvidia Jetson Xavier NX [32] 26
Fig. 3.3: Raspberry Pi 4 [32] 27
Fig. 3.4: Google Coral Dev Board [32] 29
Fig. 3.5: Rock Pi N10 [32] 31
Fig. 3.6: HiKey 970 [32] 33
Fig. 3.7: Python Logo 34
Fig. 3.8: Open Source Computer Vision Library Logo 36
Fig. 3.9: Tensor Flow Library 37
Fig. 3.10: Py Torch Library 37
Fig. 4.1: Raspberry Pi 4 Image processor Unit 39
Fig. 4.2: Training Algorithm 40
Fig. 4.3: Detecting and Recognition Algorithm 42
Fig. 5.1: Hardware 44
Fig. 5.2: Raspberry Pi Imager 45
Fig. 5.3: Select the OS 45
Fig. 5.4: Raspberry Pi 4 OS view 46
IV
Fig. 5.5: OpenCV integrate with Python 3 47
Fig. 5.6: TensorFlow integrate with Python 3 47
Fig. 5.7: Training images for different types of Brain tumors 48
Fig. 5.8: Glioma Brain Tumor Manual Annotation example 49
Fig. 5.9: Meningioma Brain Tumor Manual Annotation example 49
Fig. 5.10: Pituitary Brain Tumor Manual Annotation example 50
Fig. 5.11: Loss Graph 51
Fig. 5.12: Accuracy Graph 51
Fig. 5.13: Confusion Matrix on Test set 52
Fig. 5.14: Brain Tumour Recognition Result 1 54
Fig. 5.15: Brain Tumour Recognition Result 2 55
Fig. 5.16: Brain Tumour Recognition Result 3 55
Fig. 5.17: Brain Tumour Recognition Result 4 56
Fig. 5.18: Brain Tumour Recognition Result 5 57
Fig. 5.19: Brain Tumour Recognition Result 6 57
Fig. 5.20: Brain Tumour Recognition Result 7 58
Fig. 5.21: Brain Tumour Recognition Result 8 59
Fig. 5.22: Brain Tumour Recognition Result 9 59
Fig. 5.23: Brain Tumour Recognition Result 10 60
Fig. 5.24: Brain Tumour Recognition Result 11 60
Fig. 5.25: Brain Tumour Recognition Result 12 61

V
List of Abbreviations

AD Alzheimers Disease
AEs Auto-Encoders
AI Artificial Intelligence
CAD Computer Aided Diagnostic
CNN Convolutional Neural Network
CNS Central Nervous System
FCM Fuzzy C-means
FCNs Fully Convolutional Networks
GAN Generative Adversarial Network
HGG High-Grade Glioma
I/O Input/Output
ISLES Ischemic Stroke Lesion Segmentation Challenge
KNN K-Nearest Neighbor
LGG Low-Grade Glioma
LSTM Long Short-Term Memory
MCI Mild Cognitive Impairment
MLP Multilayer Perceptron
MRI Magnetic Resonance brain Images
OS Operating System
RNNs Recurrent Neural Networks
SBCs Single-Board Computers
SoC System-on-Chip
SVM Support Vector Machine
WHO World Health Organization

VI
Acknowledgment

First of all, we would like to thank Dr. Mohamed Saeed, who


helped us morally and materially with all the information and
also, we needed to help us to present it in this project.

We came to know about some many new things

We are really thankful to our supervisor to give us this


opportunity to provide our project

Secondly, We would like to thank our families and our friends


who supported us to complete this project within the limited
time

VII
Abstract
More than 150 types of brain tumor have been documented on the basis of

histopathologic characteristics. Brain Tumor segmentation is one of the most crucial

and arduous tasks in the terrain of medical image processing as a human-assisted

manual classification can result in inaccurate prediction and diagnosis. Moreover, it is

an aggravating task when there is a large amount of data present to be assisted. Brain

tumors have high diversity in appearance and there is a similarity between tumor and

normal tissues and thus the extraction of tumor regions from images becomes

unyielding.

In this project, a proposed method is used to extract brain tumor from 2D Magnetic

Resonance brain Images (MRI) by Convolution Neural Network algorithm which was

followed by traditional classifiers and convolutional neural network. The

experimental study will be carried on a real-time dataset with diverse tumor sizes,

locations, shapes, and different image intensities. The project will be able to detect the

brain tumor size and location using the auto encoder technique artificial intelligence

image processing for the MRI. Also, the system will classify the brain tumor type

from three types (Glioma, Meningioma, and Pituitary). The training dataset is

achieved after data collection for 1000 sample for each type for brain tumor. The

detection and recognition for the brain tumor is achieved using OpenCV, and

Tensorflow software tools. Moreover, the project will be delivered using compact

hardware (Raspberry pi 4) as independent device. The results show a detection and

recognition accuracy for the human brain tumor with 92% because it yields to a better

performance than the traditional ones.

VIII
Chapter I
INTRODUCTION

1.1 Problem Definition


Medical imaging refers to a number of techniques that can be used as non-invasive
methods of looking inside the body [1]. Medical image encompasses different image
modalities and processes to image the human body for treatment and diagnostic
purposes and hence plays a paramount and decisive role in taking actions for the
betterment of the health of the people.
Image segmentation is a crucial and essential step in image processing which
determines the success of a higher level of image processing [2]. The primary goal of
image segmentation in medical image processing is mainly tumor or lesion detection,
efficient machine vision and attaining satisfactory result for further diagnosis.
Improving the sensitivity and specificity of tumor or lesion has become a core
problem in medical images with the help of Computer Aided Diagnostic (CAD)
systems.
According to [3], Brain and other nervous system cancer is the 10th leading cause
of death, and the five-year survival rate for people with a cancerous brain is 34% for
men and 36% for women. Moreover, the World Health Organization (WHO) states
that around 400,000 people in the world are affected by the brain tumor and 120,000
people have died in the previous years [4]. Moreover, An estimated 86,970 new cases
of primary malignant and non-malignant brain and other Central Nervous System
(CNS) tumors are expected to be diagnosed in the United States in 2019 [5].
A brain tumor occurs when abnormal cells form within the brain [6]. There are two
main types of tumors- Malignant and Benign. Malignant brain tumors originate in the
brain, grows faster and aggressively invades the surrounding tissues. It can spread to
other parts of the brain and affect the central nervous system. Cancerous tumors can
be divided into primary tumors, which start within the brain, and secondary tumors,
which have spread from elsewhere, are known as brain metastasis tumors. On the
other hand, a benign brain tumor is a mass of cells that grow relatively slowly in the
brain.

1
Hence, early detection of brain tumors can play an indispensable role in improving
the treatment possibilities, and a higher gain of survival possibility can be
accomplished. But manual segmentation of tumors or lesions is a time consuming,
challenging and burdensome task as a large number of MRI images are generated in
medical routine. MRI, also known as Magnetic Resonance Imaging is mostly used for
a brain tumor or lesion detection. Brain tumor segmentation from MRI is one of the
most crucial tasks in medical image processing as it generally involves a considerable
amount of data. Moreover, the tumors can be ill-defined with soft tissue boundaries.
So it is a very extensive task to obtain the accurate segmentation of tumors from the
human brain.

1.2 Applied System


Maoguo Gong (2013), presented an improved fuzzy C-means (FCM) algorithm for
image segmentation by introducing a tradeoff weighted fuzzy factor and a kernel
metric. The tradeoff weighted fuzzy factor depends on the space distance of all
neighboring pixels and their gray-level difference simultaneously. The new algorithm
adaptively determined the kernel parameter by using a fast bandwidth selection rule
based on the distance variance of all data points in the collection. Furthermore, the
tradeoff weighted fuzzy factor and the kernel distance measure are both parameter
free. Experimental results on synthetic and real images show that the new algorithm is
effective and efficient, and is relatively independent of this type of noise.
Bhagwat et al (2013) they showed that DICOM images produce better results as
compared to non-medical images. They found that time requirement of hierarchical
clustering was least of three and that for Fuzzy C means it was highest for detection of
brain tumor. K-means algorithm produces more accurate result compared to Fuzzy c-
means and hierarchical clustering.[7]
A.Sivaramakrishnan and Dr.M.Karnan(2013) proposed a novel and an efficient
detection of the brain tumor region from cerebral image was done using Fuzzy C-
means clustering and histogram. The histogram equalization was used to calculate the
intensity values of the grey level images. The decomposition of images was done
using principle component analysis which was used to reduce dimensionality of the
wavelet coefficient. The results of the proposed Fuzzy C-means (FCM) clustering

2
algorithm successfully and accurately extracted the tumor region from brain MRI
brain images [8].
Roy et al (2012) calculated the tumor affected area for symmetrical analysis. They
showed its application with several data sets with different tumor size, intensity and
location. They proved that their algorithm can automatically detect and segment the
brain tumor. MR images gives better result compare to other techniques like CT
images and X-rays.. Image pre-processing includes conversion of RGB image into
grayscale image and then passing that image to the high pass filter in order to remove
noise present in image [9].
B. Sathya et al (2011), proposed four clustering algorithm; k mean, improved k
mean, c mean and improved c mean algorithm. They did an experimental analysis for
large database consisting of various images. They analyzed the results using various
parameters.
Hui Zhang et al (2008), compared subjective and supervised evaluation
methodology for image segmentation. Subjective evaluation and supervised
evaluation, are infeasible in many vision applications, so unsupervised methods are
necessary. Unsupervised evaluation enables the objective comparison of both
different segmentation methods and different parameterizations of a single method
[10].
Martial Heber et al (2005), presented an evaluation of two popular segmentation
algorithms, the mean shift-based segmentation algorithm and a graph-based
segmentation scheme.

1.3 Main Objectives


1. Apply the train images of brain cancer MRI images.

2. Apply the image preprocessing techniques for the MRI image.

3. Apply image segmentation for the brain tumor image.

4. Determine skull striping using AI technique.

5. Implement feature extraction in the image captured.

6. Build the knowledge base for the brain cancer images.

7. Apply identification and feature extraction algorithms.

3
8. Evaluate the tumor classification for benign, and malign.

1.4 Methodology

Fig. 1.1: Detection of Brain Cancer Flow Chart1

The Detection of Brain Cancer Flow Chart in Figure 1.1 will start by:
• Importing the MR image of the human brain to the image processing board.
• Apply Image preprocessing for the human brain MR image.
• Apply image segmentation for different human brain MR image.
• Apply feature extraction and selection for the human brain MR images.
4
• Decide in the tumor Classification either the human brain MR image:
o The image is benign
o The image is Malign
• Finally display the result over the image imported.
• The flow chart end.

1.5 Software
1 Raspberry Pi 4
2 OpenCV
3 TensorFlow
4 Jupiter Notebook
5 Deep learning
6 Spyder IDE.

1.6 Report organization


After an introduction to the project in Chapter1 and defining the problem definition
that we are facing in the project, a review of literatures including the previous and
current alternative systems is presented in Chapter 2.

In Chapter 3, proposed system, and the main components are presented and
illustrated to define the functionality of these component in the project.

In Chapter 4, discuss the cost analysis of the project prototype that will be built.

While in Chapter 5, discuss the time plane.

Finally, the main conclusions of this project and the future work plan are discussed
in Chapter 6.

5
Chapter II
Brain Cancer Detection Survey
2.1 Introduction
This introduction, will present the research challenges, Related Problems, Data
Collection, and Contribution of this survey.

2.1.1 Research Challenges


Despite significant progress that has been made in brain tumor segmentation, state-
of-the-art deep learning-based methods still experience unsatisfactory outcomes with
several challenges to be solved. The challenges associated with brain tumor
segmentation can be categorized as follows:

Location Uncertainty:

Glioma is mutated from gluey cells, which is a kind of supportive cell surrounding
nerve cells. Due to the wide spatial distribution of gluey supportive cells, either High-
Grade Glioma (HGG) or Low-Grade Glioma (LGG) can appear at any location inside
the brain.

Morphological Uncertainty:

Differ from a rigid object, the morphology, e.g. shape and size, of different
patients’ brain tumors can vary with large uncertainty. As the external layer of a brain
tumor, or edema tissues, show different fluid structures, which barely provide any
prior information for describing the tumor shapes. The subregions of a tumor may
also vary in shape and size.

Diffusion and Low Contrast:

High resolution images with multi-modality channels (such as T1 and T2 in MRI)


in high contrast are expected to contain more image information [11]. Due to the
image projection and tomography process, the sliced images are common in low
quality, most in diffusion and low contrast. The boundary between biological tissues
tends to be blurred and hard to detect. Cells nearby the boundary are hard to be

6
classified. This limits the automated algorithms to extract sufficient information for
further processing.

Annotation Bias:

Manual annotation highly depends on personal experience, which can introduce an


annotation bias during dataset labeling. As the exemplar cases are shown in Fig. 2.1
(a), some annotations tend to connect all the small regions into a large region while
the other annotation tends to label the voxels individually, thus the ground truth
annotation tends to be sparse. The annotation biases have a huge impact on the
detection algorithm which may be confused by the biases during the learning and
processing.

Imbalanced Issue:

As the examples are shown in Fig. 2.1 (b) and (c), there exists an unbalanced
number of voxels in different tumor regions. For example, the NCR/ECT region is
much smaller than the other two regions. The imbalanced issue can affect the learning
algorithm as well, as the extracted features may be highly dominated by large tumor
regions.

Fig. 2.1: Challenges in segmenting brain glioma tumors, glioma tumor exemplars,
statistical information of the training set [11].2

7
2.1.2 Related Problems
There are a number of unsolved problems in brain tumor segmentation. Brain
tissue segmentation or anatomical brain segmentation aims to label each voxel or
pixel into a unique brain tissue class. This segmentation assumption is that the brain
image does not contain any tumor tissue or other anomalies [12], [13]. The goal of
white matter lesion segmentation is to segment the white matter region from the
normal tissue. The white matter lesion itself does not contain sub-regions such as
necrotic and cores, where segmentation may be achieved based on binary
classification methods. Tumor detection aims to detect abnormal tumors or lesion
tissues and report the predicted class of each tissue.

This returns the bounding box as the detection result and the label as the classified
result [14], [15], [16]. It is worth mentioning that some research works with the words
“brain tumor detection” only return the bounding box of the tumor tissue as the
detection result. Some research methods return the single label segmentation mask or
the center of the tumor core as the point of interest without performing further
reasoning and segmentation. In this chapter, we focus on glioma tumor segmentation
and sub-region voxel (or pixel) level segmentation. Disorder diagnosis is to extract
pre-defined features from brain scan images and then classify feature representations
into pre-specified disorders such as High-Grade-Glioma (HGG) vs Low-Grade-
Glioma (LGG), Mild Cognitive Impairment (MCI) [17], Alzheimers Disease (AD)
[18] and Schizophrenia [19]. Disorder diagnosis relies on classification algorithms
that do not normally need segmentation masks. Survival Prediction concerns
identifying tumors’ patterns and activities [20] in order to predict the survival rate of a
patient [21]. Survival prediction normally returns a survival rate as a supplementary
of the clinical diagnosis, which can be regarded as the down-stream regression task of
tumor segmentation or disease diagnosis.

2.1.3 Data Collection


In this survey, the data that have been collected and summarized the research
studies reported on over one hundred scientific papers. Google Scholar and IEEE
Xplore are the major search engines. We also retrieved major journals in the scientific
community including Medical Image Analysis and IEEE Transactions on Medical
Imaging. Furthermore, we evaluate proceedings from relevant major conferences,
8
such as ISBI, MICCAI, CVPR, ICCV, and NIPS, to retain frontier research outcomes.
We examine annual challenges and their related competition entries such as The
Multimodal Brain Tumor Segmentation Challenge (MICCAI BRATS) and Ischemic
Stroke Lesion Segmentation Challenge (ISLES). In addition, some of the established
methods’ pre-printed versions on arXiv are also included as a source of information.

Fig. 2.2: Data Collection for Brain Tumours [18].3

2.1.4 Contribution of this survey


With the breakthrough improvement made by deep learning in recent years,
numerous deep learning-based methods have been published on brain tumor
segmentation and achieved promising results. This paper, as a platform, provides a
comprehensive and critical survey of the current deep learning-based brain tumor
segmentation methods. We anticipate that this survey supplies useful guidelines and
9
coherent technical insights for someone who chooses deep learning as a development
tool for brain tumor segmentation. This survey makes these contributions:

(1) provide a summary of current state-of-the-art deep learning-based brain tumor


segmentation algorithms.

(2) categorize deep learning-based brain tumor segmentation algorithms according


to different structures or pipelines.

(3) discuss the challenges, open issues and potential working perspectives for deep
learning-based brain tumor segmentation.

Fig. 2.3: A taxonomy of this survey for deep learning-based brain tumour segmentation
[20].4

2.2 Deep Learning Based Brain Tumor Segmentation


Methods
Researchers have considered deep learning as a rising subset of machine learning
techniques. Rather than using pre-defined hand-crafted features, deep neural networks
can learn hierarchical features thoroughly from the input images. A sketch
comparison between traditional and deep learning based brain tumor segmentation
algorithms is shown in Figure 2.4.

10
Fig. 2.4: A sketch comparison between traditional and deep learning based brain tumor
segmentation algorithms [21].5

2.2.1 Convolutional Neural Network Based Methods


Convolutional neural networks, often known as CNNs, have a strong ability in
processing and learning features from images and videos. A CNN typically contains
convolutional layers and pooling layers followed by an activation layer and finally a
fully connected layer. CNNs have been widely used as the backbone network in
various deep neural network applications. Here, we divide the CNN based methods
into four categories: (1) single-path CNN, (2) multi-path CNN, (3) fully convolutional
networks (FCNs), and (4) cascaded architecture.

Fig. 2.5: Convolutional Neural Network [20].6

11
2.2.1.1 Single-Path and Multi-Path CNN:

Single path neural networks contain a Single path neural networks contain a single
flow of data processing where the network starts to sample the input image with
convolutional layers. This is followed by the pooling layer and non-linear rectifier
layers [22]. In [23] use single-path networks due to computational efficiency.
Compared with single-path networks, multi-path convolutional neural networks can
extract different features from different processing pathways with different scales.
The extracted features are then combined or concatenated together for further
processing. A common interpretation is that the path with a large scale kernel can
learn features from a larger reception field known as global features.
2.2.1.2 Fully Convolutional Based:

In the early stage of using CNNs for image classification, the final layer is a fully
connected layer that produces a single value. The output of the final fully connected
layer can be interpreted as the predicted label with the highest probability. Long et al.
[24] introduced fully convolutional networks which use a deconvolutional layer to
replace the final fully connected layer and predict segmentation masks directly. In the
fully convolutional networks, the final fully connected layer is replaced by the
deconvolutional layer for up-sampling that transforms the down-sampled feature map
back to the original spatial size. FCNs therefore can be trained in an image-to-
segmentation map fashion and have computational efficiency over the CNN patch
classifiers. One well recognized variant of FCNs, known as U-Net [25] and its related
usage on brain tumor segmentation will be discussed later.

Fig. 2.6: Fully Convolutional Neural Network Based [25].7

12
2.2.1.3 Cascaded CNN:

Spatial information, such as spatial inclusion relationship, can be applied as prior


auxiliary knowledge for image segmentation, e.g. a common property of biological
tissues is that the core of a tumor is surrounded by extended edema tissues. Such kind
of properties can be used either on the processing stage to segment sub-regions, or on
the refining stage to remove false positive segmentation. Another problem is that the
pixels of anomaly regions only occupy a low percentage, compared to the background
pixels and normal tissue pixels. The imbalance between the positive pixel samples
(anomaly regions, e.g., tumors and lesions) and negative pixel samples (background
and normal tissue pixels) may introduce prediction biases to the training models.
Using a sub-region hierarchy to reduce the imbalance noise, various cascaded network
structures have been proposed for brain tumor sub-region segmentation. Wang et al.
[26] presented cascaded convolutional neural networks using sub-region hierarchical
information to decompose a multi-class segmentation problem into three binary
segmentation problems. The first network takes multi-modal MRI images as input and
the segmentation mask with a bounding box of the entire tumor is obtained. Using the
bounding box, the cropped slice is used as the input of the second network to segment
the tumor core from the tumor. This procedure repeats again for the third network to
segment the enhancing core from the tumor core. Bounding boxes and cropped slices
are generated from the ground truth annotation for network training. In the testing
stage, a binary segmentation output is inferred and used as the input for the next stage,
which serves as the anatomical constraints for the segmentation. The authors used a
stack of slices as input with a large receptive field in 2D and a relatively small
receptive field in the out-plane direction that is orthogonal to the 2D slices. In each
network, dilated convolution and residual connections are used, where the dilated
convolution kernel enlarges the receptive field and the residual connection allows a
functional block to learn residual functions with reference to the input.

13
Fig. 2.7: Fully Convolutional Neural Network Based [26].8

2.2.1.4 Summary:

Convolutional neural network based models have recently become a popular


method in image processing. Convolutional kernels can help efficiently extract
features of low or high dimensions and the pooling layer used in the networks can
learn translation invariance and also reduce the system parameters’ number by
reducing feature dimensionality. Various applications have shown research and
practical values of using convolutional neural networks based models for brain tumor
segmentation. As the extension of single path feed-forward CNNs, multi-path CNNs
aim to extract different features from either a global or a local field, or different
features from different modalities. Fully convolutional networks aim to reconstruct an
image using deconvolutional layers. FCNs take input patches in any size and reduce
the parameter size by replacing fully connected layers with deconvolutional layers.
The main shortcoming of FCNs is that the result of the up-sampling operation tends to
be blur and not sensitive to the small details of images, which limits their performance
in medical image analysis. Cascaded networks can take subregions’ spatial
relationships into account, although it is harder to train multiple sub-networks than

14
training a single end-toend network. Selected CNNs based methods comparison is
shown in Table 2.1.

Table 2.1 Comparison of CNN Based Methods1

2.2.2 Recurrent Neural Network Based


Recurrent Neural Networks (RNNs) are first created for handling the sequential
process problems, where the current output depends on the current input and the
representation of the previous inputs. One mutant of recurrent neural networks is
Long Short-Term Memory (LSTM) networks The historical information can be stored
and processed over a long sequence inside the LSTM cell. For a two dimensional
image, LSTM connects hidden units in grid-like four directions, i.e. up, down, left and
right. Graves et al. [27] and Byeon et al. [28] reported pioneer works for applying
Multi-Dimensional LSTMs to image classification and segmentation tasks. The
LSTM units recursively gather information from the predeceasing LSTM units based
on adjacent pixels. Rather than processing 3D voxel data using 2D slices, 3D LSTMs
can directly process full voxel contexts through 8 adjacent voxels in 8 sweeps (each
sweep is the direction of one of the 8 directed volume diagonals).

15
Fig. 2.8: Recurrent Neural Network Based [27].9

2.2.3 Deep Generative Model Based


Deep neural networks still face several challenges. First, like many supervised
methods, deep neural networks hold the same hypothesis as the traditional machine
learning techniques that can only handle the testing data with the same distribution as
the training data. In real world datasets, there exists a discrepancy between the
distributions of the testing and training data. This may lead to the bias prediction
problem or model over-fitting. Secondly, the dataset labeling is labor consuming and
time consuming, especially for a dense pixellevel segmentation dataset in medical
applications. Another drawback is the majority of deep learning models focus on pixel
level classification whilst ignoring the relation or connection between adjacent pixels.
This may lead to high accuracy in pixel level classification but the segmentation result
is inconsistent due to the variations in size and shape of the targets.

2.2.3.1 Generative Adversarial Networks:

As a rising sub-set of generative models, generative adversarial network (GAN)


[29] was proposed to tackle the above issues. The generator and the discriminator play
a min-max game to optimize the model which can produce the result close enough to
the ground truth as expected. Lu et al. [30] proposed the pioneer work of applying
GANs onto image semantic segmentation, where the discriminator needs to report the
difference between the ground truth segmentation and the actual segmentation masks.
The experiment results also show that this method reduces the over-fitting
opportunity.

16
Fig. 2.9: Generative Adversarial Networks [30].10

2.2.3.2 Auto-Encoders:

Another group of unsupervised brain tumor segmentation method are based on


auto-encoders (AEs). Generative adversarial networks optimize the generator that can
learn a latent representation of random samples from a prior distribution where the
optimized discriminator cannot correctly distinguish.

Fig. 2.10: Auto-Encoders [30].11

2.2.3.3 Summary:

With the capability of learning the latent representation and reconstructing,


research focus on data augmentation by generating synthetic data using unsupervised
models. Although recent unsupervised models have been proposed on image
reconstruction and anomaly detection, there are still remaining issues within the
unsupervised anomaly detection area. An overview in [31] of the current state of
17
unsupervised medical image detection and segmentation models has been carried out.
Possible improvement is that the tumor segmentation is based on the reconstruction
error, which also can help to improve the pixel-wise probability estimation. Another
issue is that an unsupervised model requires complicated post processing such as
noise removal with manual settled thresholds, which may not be ideal for an
automated framework. An adaptive way of post-processing should be developed.
Selected deep generative model based methods and their comparison are shown in
Table 2.2.
Table 2.2: Comparison of RNN Based Methods2

2.3 Object Detection Methods


Object Detection is modeled as a classification problem where we take windows of
fixed sizes from input image at all the possible locations feed these patches to an
image classifier.

Fig. 2.11: Object Detection example [21].12

As you can see that the object can be of varying sizes. To solve this problem an
image pyramid is created by scaling the image.Idea is that we resize the image at
multiple scales and we count on the fact that our chosen window size will completely
contain the object in one of these resized images. Most commonly, the image is
downsampled(size is reduced) until certain condition typically a minimum size is
reached. On each of these images, a fixed size window detector is run. It’s common to
have as many as 64 levels on such pyramids. Now, all these windows are fed to a

18
classifier to detect the object of interest. This will help us solve the problem of size
and location.

2.3.1 Region-based Convolutional Neural Networks(R-CNN):


Since we had modeled object detection into a classification problem, success
depends on the accuracy of classification. After the rise of deep learning, the obvious
idea was to replace HOG based classifiers with a more accurate convolutional neural
network based classifier. However, there was one problem. CNNs were too slow and
computationally very expensive. It was impossible to run CNNs on so many patches
generated by sliding window detector. R-CNN solves this problem by using an object
proposal algorithm called Selective Search which reduces the number of bounding
boxes that are fed to the classifier to close to 2000 region proposals. Selective search
uses local cues like texture, intensity, color and/or a measure of insideness etc to
generate all the possible locations of the object. Now, we can feed these boxes to our
CNN based classifier. Remember, fully connected part of CNN takes a fixed sized
input so, we resize(without preserving aspect ratio) all the generated boxes to a fixed
size (224×224 for VGG) and feed to the CNN part. Hence, there are 3 important parts
of R-CNN:

• Run Selective Search to generate probable objects.


• Feed these patches to CNN, followed by SVM to predict the class of each patch.
• Optimize patches by training bounding box regression separately.

19
Fig. 2.12: R-CNN Architecture.13

2.3.2 Faster R-CNN:


So, what did Faster RCNN improve? Well, it’s faster. And How does it achieve
that? Slowest part in Fast RCNN was Selective Search or Edge boxes. Faster RCNN
replaces selective search with a very small convolutional network called Region
Proposal Network to generate regions of Interests.

Fig. 2.13: Faster R-CNN Architecture.14

20
To handle the variations in aspect ratio and scale of objects, Faster R-CNN
introduces the idea of anchor boxes. At each location, the original paper uses 3 kinds
of anchor boxes for scale 128x 128, 256×256 and 512×512. Similarly, for aspect ratio,
it uses three aspect ratios 1:1, 2:1 and 1:2. So, In total at each location, we have 9
boxes on which RPN predicts the probability of it being background or foreground.
We apply bounding box regression to improve the anchor boxes at each location. So,
RPN gives out bounding boxes of various sizes with the corresponding probabilities
of each class. The varying sizes of bounding boxes can be passed further by apply
Spatial Pooling just like Fast-RCNN. The remaining network is similar to Fast-
RCNN. Faster-RCNN is 10 times faster than Fast-RCNN with similar accuracy of
datasets like VOC-2007. That’s why Faster-RCNN has been one of the most accurate
object detection algorithms. Here is a quick comparison between various versions of
RCNN.

Table 2.3: Comparison of R-CNN Vs Fast R-CNN Vs Faster R-CNN3

2.3.3 YOLO(You only Look Once):


For YOLO, detection is a simple regression problem which takes an input image
and learns the class probabilities and bounding box coordinates. Sounds simple?

YOLO divides each image into a grid of S x S and each grid predicts N bounding
boxes and confidence. The confidence reflects the accuracy of the bounding box and
whether the bounding box actually contains an object(regardless of class). YOLO also
predicts the classification score for each box for every class in training. You can
combine both the classes to calculate the probability of each class being present in a
predicted box.

So, total SxSxN boxes are predicted. However, most of these boxes have low
confidence scores and if we set a threshold say 30% confidence, we can remove most
of them as shown in the example below.

21
Fig. 2.14: YOLO Architecture.15

Notice that at runtime, we have run our image on CNN only once. Hence, YOLO
is super fast and can be run real time. Another key difference is that YOLO sees the
complete image at once as opposed to looking at only a generated region proposals in
the previous methods. So, this contextual information helps in avoiding false
positives. However, one limitation for YOLO is that it only predicts 1 type of class in
one grid hence, it struggles with very small objects.

2.3.4 Single Shot Detector(SSD):


Single Shot Detector achieves a good balance between speed and accuracy. SSD
runs a convolutional network on input image only once and calculates a feature map.
Now, we run a small 3×3 sized convolutional kernel on this feature map to predict the
bounding boxes and classification probability. SSD also uses anchor boxes at various
aspect ratio similar to Faster-RCNN and learns the off-set rather than learning the
box. In order to handle the scale, SSD predicts bounding boxes after multiple
convolutional layers. Since each convolutional layer operates at a different scale, it is
able to detect objects of various scales.

That’s a lot of algorithms. Which one should you use? Currently, Faster-RCNN is
the choice if you are fanatic about the accuracy numbers. However, if you are
strapped for computation(probably running it on Nvidia Jetsons), SSD is a better
recommendation. Finally, if accuracy is not too much of a concern but you want to go
super fast, YOLO will be the way to go. First of all a visual understanding of speed vs
accuracy trade-off:

22
Fig. 2.15: Accuracy vs speed chart.16

SSD seems to be a good choice as we are able to run it on a video and the accuracy
trade-off is very little. However, it may not be that simple, look at this chart that
compares the performance of SSD, YOLO, and Faster-RCNN on various sized
objects. At large sizes, SSD seems to perform similarly to Faster-RCNN. However,
look at the accuracy numbers when the object size is small, the gap widens.

Fig. 2.16: YOLO vs SSD vs Faster-RCNN for various sizes.17

23
Chapter III
Proposed Early Detection of Brain Cancer
Using AI.
3.1 Block Diagram
The block diagram of training and testing phase are presented in Figure 3.1, the
training phase will be built by importing the train images for the brain MRI. The
second block will operate preprocessing task to equalize the histogram of the gray
image. The third block will get the feature extraction that are in the MRI images of
the human brain. The fourth block will operate a classification task for Glioma,
Meningioma, Pituitary.
The other phase is testing phase, the first block is used to import the test images of
the human brain MRI, then the second block will be used to operate preprocessing of
the image, the third block will operate feature extraction to get the features to identify
in the last block the image of the MRI.

Fig. 3.1: Train and Testing block diagram.18

24
3.2 Hardware Tools
In this section, the hardware that can be used in our project will be presented .
Where once artificial intelligence (AI) was relegated to supercomputers, now makers
at home may dabble with AI applications. The likes of Google AIY Vision and Voice
kits enable do-it-yourselfers (DIYers) and hobbyists to create artificial intelligence
applications from the comfort of their own homes. Similarly, single-board computers
(SBCs) have become increasingly powerful, to the point where many development
boards are capable of AI use such as machine learning and natural language
processing. Check out the best single-board computers for artificial intelligence!

3.2.1 Nvidia Jetson Xavier NX


Dubbed the world's smallest AI supercomputer, the Nvidia Jetson Xavier NX
boasts a whopping 21 TOPS (tera operations per second) of compute on a mere 15W
of power. And at just 10W, the Xavier NX clocks around 14 TOPS. That's incredibly
powerful yet energy-efficient. Its ultra-small 70-45mm footprint takes up little space
but packs in a 6-core NVIDIA Carmel ARM v8.2 64-bit CPU with a 384-core
NVIDIA Volta GPU and 48 Tensor cores. Its spec sheet is incredibly impressive.
In benchmarking tests, the NVIDIA Jetson Xavier NX blew its younger siblings in
the Jetson Nano and Jetson TX2 out of the water. While the Jetson AGX Xavier
trounced the Xavier NX, the NX is certainly no slouch. Unfortunately, it does not
come cheap. Expect to shell out around $400 for the Nvidia Jetson Xavier NX,
compared to $100 for the Jetson Nano. For less demanding AI applications, the Jetson
Nano should work just fine. But if you need supercomputer capabilities, the NVIDIA
Jetson Xavier NX is a top choice.

25
Fig. 3.2: Nvidia Jetson Xavier NX [32].19

Pros:
• AI-capable - handles machine learning, natural language processing, and
more
• Great for robotics
• Excellent for desktop use
• Fantastic for high-end retro gaming emulation
• Great I/O - Wi-Fi, Bluetooth, USB 3.1, GPIO, HDMI/DisplayPort
• Up to 21 TOPS of computer power
• 4K video output
• Small form factor
Cons:
• Expensive
• Larger than Raspberry Pi and its alternatives

26
Nvidia Jetson Xavier NX specs:
• CPU: 6-core NVIDIA Carmel 64-bit ARMv8.2 @ 1400MHz* (6MB L2 +
4MB L3)
• GPU: 384-core NVIDIA Volta @ 1100MHz with 48 Tensor Cores
• Dual NVIDIA Deep Learning Accelerator (NVDLA) engines
• 8GB 128-bit LPDDR4x @ 1600MHz | 51.2GB/s
• 16GB eMMC
• x DisplayPort 1.4, eDP 1.4, HDMI 2.0 @4Kp60
• 10/100/1000 BASE-T Ethernet
• USB 3.1, 3 x USB 2.0

3.2.2 Raspberry Pi 4

Fig. 3.3: Raspberry Pi 4 [32].20

Clocking in at a starting price of $35, the Raspberry Pi 4 is a cost-effective maker


board, and the most popular SBC on the planet. It's incredibly well-documented and
supported. With a revamped system-on-a-chip (SoC) and available with 2GB, 4GB, or
8GB of DDR4 RAM, the Raspberry Pi 4 is a fantastic SBC for AI. You can image
classification, object detection, and a ton of other artificial intelligence projects.
TensorFlow runs much faster on the Raspberry Pi 4 than its Raspberry Pi 3
predecessor. And with USB 3.0 ports, throughput is drastically improved.

27
What's more, a slew of third-party accessories transforms the Pi 4 into an excellent
AI device. The Intel Neural Compute Stick 2 can be plugged into the Raspberry Pi 4
and provides an artificial intelligence framework via USB connectivity. Alternatively,
the Coral Edge TPU USB accelerator pairs well with the Pi. And Google offers its
AIY Vision and Voice kits that enable at-home makers to tinker with artificial
intelligence, building neat projects ranging from object identification systems to
autonomous vehicles. With an ultra-affordable price tag and a plethora of AI
accessories such as the Intel Neural Compute Stick and Google AIY kits, the
Raspberry Pi 4 is the best single-board computer for artificial intelligence for most
makers.
Pros:
• Versatile
• Affordable
• Several different RAM options
• Easy to use
• Excellent price-to-performance ratio
• Small footprint
• Low power draw
• Great OS compatibility - Linux, Android, Chrome OS, non-Linux OSes
Cons:
• Not a true desktop replacement
• More powerful SBCs available
Raspberry Pi 4 specs:
• Broadcom BCM2711, Quad-core Cortex-A72 (ARM v8) 64-bit SoC @
1.5GHz
• 1GB, 2GB, 4GB, or 8GB LPDDR4-2400 SDRAM (depending on model)
• 2.4 GHz and 5.0 GHz IEEE 802.11ac wireless, Bluetooth 5.0, BLE
• Gigabit Ethernet
• USB 3.0 ports; 2 USB 2.0 ports.
• Raspberry Pi standard 40 pin GPIO header (fully backwards compatible with
previous boards)
• × micro-HDMI ports (up to 4kp60 supported)
• 2-lane MIPI DSI display port
28
• 2-lane MIPI CSI camera port
• 4-pole stereo audio and composite video port
• H.265 (4kp60 decode), H264 (1080p60 decode, 1080p30 encode)
• OpenGL ES 3.0 graphics
• MicroSD card slot for loading operating system and data storage
• 5V DC via USB-C connector (minimum 3A*)
• 5V DC via GPIO header (minimum 3A*)
• Power over Ethernet (PoE) enabled (requires separate PoE HAT)
• Operating temperature: 0 – 50 degrees C ambient

3.2.3 Google Coral Dev Board

Fig. 3.4: Google Coral Dev Board [32].21

The Google Coral Dev Board is a nifty SBC for quick, easy edge computing
prototyping. There's a removable system-on-module and two tera operations per
second 9TOPS) per watt, both of which make the Coral Dev Board suitable for low-
cost AI DIYing. At its core is an NXP i.MX 8M system-on-a-chip (SoC) with an
integrated GC7000 Lite GPU. And of course, there's the Google Edge TPU co-
processor, 8GB of eMMC flash storage, 1GB of LBDDR4 RAM, plus Wi-Fi and
Bluetooth. The Google Coral Dev Board functions for industrial AI applications, and
with a low power draw, it's easily scalable. Documentation of the Coral Dev Board as
well as its Mendel operating system (OS) is top-notch. You'll find ample official and

29
third-party resources such as help documents and sample projects. Plus, add-ons such
as the Coral Camera allow for a modular experience. However, it's probably best for
artificial intelligence enthusiasts with an intended purpose rather than curious
newcomers. If you're merely interested in learning more about AI through hands-on
experience, a Raspberry Pi 4 plus the Google Coral USB TPU accelerator is a better
starting spot.
Pros:
• On-device machine learning with Edge TPU
• Powerful quad-core Cortex A-53 SoC
• 1GB DDR4
Cons:
• Expensive
• Not capable of desktop use
Google Coral Dev Board specs:
• CPU: NXP i.MX 8M SOC (quad Cortex-A53, Cortex-M4F)
• GPU: Integrated GC7000 Lite Graphics
• Onboard Google Edge TPU
• 1GB LPDDR4

30
3.2.4 Rock Pi N10

Fig. 3.5: Rock Pi N10 [32].22

Boasting 4GB, 6GB, or 8GB of LPDDR3, a Rockchip RK3399 with an NPU


designed for AI and deep learning, the Rock Pi N10 Model A is a SBC built with
artificial intelligence in mind. There's support for Linux operating systems such as
Debian and even Android OSes. Its Mali T860MP4 GPU is powerful. In addition to a
microSD card slot, the Rock Pi N10 sports an M.2 SSD connector that supports up to
2TB of SSD storage. Although Wi-Fi isn't baked in, the optional Rock Pi wireless
module easily lets you add wireless networking to your project. There's great
input/output (I/O) support with a 40-pin GPIO (general purpose input-output) header.
Ultimately, the Rock Pi N10 which retails for around $100, is a great choice for
hobbyists seeking to start tinkering with AI but don't want to break the bank.
Pros:
• Dedicated NPU with 3.0 TOPS
• Up to 8GB of DDR3
• Powerful RK3399Pro and Mali T860MP4
• 16GB of eMMC
• M.2 SSD connector
31
• Full-size HDMI with 4K@60 support
Cons:
• Only DDR3, not DDR4
• No built-in Wi-Fi or Bluetooth
Rock Pi N10 specs:
• CPU: RK3399Pro dual Cortex-A72, frequency 1.8GHz with quad Cortex-
A53, frequency 1.4GHz
• GPU: Mali T860MP4 GPU, OpenGL ES 1.1 /2.0 /3.0 /3.1 /3.2, Vulkan 1.0,
Open CL 1.1 1.2, DX1\
• NPU with 3.0 TOPS of compute power
• Up to 8GB of 64-bit dual-channel LPDDR3@1866Mb/s, 3GB for CPU/GPU,
1GB for NPU
• 16GB eMMC module, microSD card slot, M.2 SSD connector
• Full-size HDMI 2.0 with 4K@60 support
• MIPI DSI 2-lane connector
• 3.5mm audio jack
• MIPI CSI 2-lane connector
• 1 x USB 3.0 OTG, 2 x USB 2.0
• Gigabit LAN Ethernet port, optional Wi-Fi and Bluetooth module
• 40-pin GPIO header

32
3.2.5 HiKey 970

Fig. 3.6: HiKey 970 [32].23

Hailing from 96Boards, the HiKey970 concentrates on artificial intelligence.


Packing a beefy HiSilicon Krin 970 SoC and an HiAI architecture, the HiKey970
includes an NPU. You'll also find LPDDR4X 1866MHz RAM, 64GB UFS 2.1
storage, Wi-Fi, Bluetooth, and GPS. And the board itself is capable of running
Android and Linux. While it doesn't come cheap, selling for around $300, it's still an
artificial intelligence SBC worth considering. Aside from its competency for deep
learning, the HiKey970 is one of the best SBCs for robotics.
Pros:
• 6GB of LPDDR4 RAM
• Quad-core Cortex-A73 and quad-core Cortex-A53 processor
• 64GB UFS storage

33
• Great connectivity - Gigabit Ethernet, GPS, PCIe gen2
• Dedicated NPU for AI
• Capable of AI, deep learning, robotics, and more
Cons:
• Expensive
Hikey 970 specs:
• Dimensions - 100 mm x 85 mm x 10 mm
• ARM Cortex A53, ARM Cortex A73
• Operating Supply Voltage - 12 V
• Tool Is For Evaluation Of - Kirin 970 SoC
• 6GB LPDDR4 RAM
• 64GB UFS storage
• Gigabit Ethernet
• GPS
• PCIe gen2
• Dedicated NPU
3.3 Software Tools
In this section we will discus the software that can be used in the project such as
Python, Opencv, TensorFlow, and Pytorch.

3.3.1 Python
Python is an object-oriented programming language that is designed in C. By
nature, it is a high-level programming language that allows for the creation of both
simple as well as complex operations. Along with this Python comes inbuilt with a
wide array of modules as well as libraries which allows it to support many different
programming languages like Java, C, C++, and JSON.

Fig. 3.7: Python Logo.24

34
1. Easy Language
Python is an easy language. It is easy to read, write, learn and understand. Python
has a smooth learning curve. It is easy to learn. Python has a simple syntax and
Python code is easy to understand. Since it’s easy to understand, you can easily read
and understand someone else’s code. Python is also easy to write because of its
simple syntax. Because it is an easy language, it is used in schools and universities to
introduce students to programming. Python is for both startups and big companies.
2. Readable
The Python language is designed to make developers life easy. Reading a Python
code is like reading an English sentence. This is one of the key reason that makes
Python best for beginners. Python uses indentation instead of curly braces, unlike
other programming languages. This makes the code look clean and easier to
understand.
3. Interpreted Language
Python is an interpreted language. It comes with the IDLE (Interactive
Development Environment). This is an interpreter and follows the REPL structure
(Read-Evaluate-Print-Loop). It executes and displays the output of one line at a time.
So it displays errors while you’re running a line and displays the entire stack trace for
the error.
4. Dynamically-Typed Language
Python is not statically-typed like Java. You don’t need to declare data type while
defining a variable. The interpreter determines this at runtime based on the types of
the parts of the expression. This is easy for programmers but can create runtime
errors.
5. Object-Oriented
Python is object-oriented but supports both functional and object-oriented
programming. Everything in Python is an object. It has the OOP (Object-oriented
programming) concepts like inheritance and polymorphism.
6. Popular and Large Community Support
Python has one of the largest communities on StackOverflow and Meetup. If you
need help, the community will answer your questions. They also already have many
answered questions about Python.
7. Open-Source

35
Python is open-source and the community is always contributing to it to improve
it. It is free and its source code is freely available to the public. You can download
Python from the official Python Website.
8. Large Standard Library
The standard library is large and has many packages and modules with common
and important functionality. If you need something that is available in this standard
library, you don’t need to write it from scratch. Because of this, you can focus on
more important things. You can also install packages from the PyPI (Python Package
Index) if you want even more functionality.
9. GUI Support
You can use Python to create GUI (Graphical User Interfaces). You can use
tkinter, PyQt, wxPython or Pyside for this. Python features a huge number of GUI
frameworks available for it to variety of other cross-platform solutions. It binds to
platform-specific technologies.

3.3.2 OpenCV
OpenCV is written in C++ and its primary interface is in C++, but it still retains a
less comprehensive though extensive older C interface. All of the new developments
and algorithms appear in the C++ interface. There are bindings in Python, Java and
MATLAB/OCTAVE. The API for these interfaces can be found in the online
documentation. Wrappers in several programming languages have been developed to
encourage adoption by a wider audience. In version 3.4, JavaScript bindings for a
selected subset of OpenCV functions was released as OpenCV.js, to be used for web
platforms.

Fig. 3.8: Open Source Computer Vision Library Logo.25

36
3.3.3 Tensor Flow
TensorFlow is Google Brain's second-generation system. Version 1.0.0 was
released on February 11, 2017. While the reference implementation runs on single
devices, TensorFlow can run on multiple CPUs and GPUs (with optional CUDA and
SYCL extensions for general-purpose computing on graphics processing units).
TensorFlow is available on 64-bit Linux, macOS, Windows, and mobile computing
platforms including Android and iOS.
Its flexible architecture allows for the easy deployment of computation across a
variety of platforms (CPUs, GPUs, TPUs), and from desktops to clusters of servers to
mobile and edge devices.
TensorFlow computations are expressed as stateful dataflow graphs. The name
TensorFlow derives from the operations that such neural networks perform on
multidimensional data arrays, which are referred to as tensors. During the Google I/O
Conference in June 2016, Jeff Dean stated that 1,500 repositories on GitHub
mentioned TensorFlow, of which only 5 were from Google.

Fig. 3.9: Tensor Flow Library.26

3.3.4 Py Torch
PyTorch is an open source machine learning library based on the Torch library,
used for applications such as computer vision and natural language processing,
primarily developed by Facebook's AI Research lab (FAIR). It is free and open-source
software released under the Modified BSD license. Although the Python interface is
more polished and the primary focus of development, PyTorch also has a C++
interface.

Fig. 3.10: Py Torch Library.27


37
PyTorch defines a class called Tensor (torch.Tensor) to store and operate on
homogeneous multidimensional rectangular arrays of numbers. PyTorch Tensors are
similar to NumPy Arrays, but can also be operated on a CUDA-capable Nvidia GPU.
PyTorch supports various sub-types of Tensors.
Note that the term "tensor" here does not carry the same meaning as in
mathematics or physics. The meaning of the word in those areas is only tangentially
related to the one in Machine Learning. In mathematics, a tensor is a certain kind of
object in linear algebra, while in physics the term "tensor" usually refers to what
mathematicians call a tensor field.

38
Chapter IV
System Design
4.1 Top Level Circuit

4.1.1 Image processor Module:

Fig. 4.1: Raspberry Pi 4 Image processor Unit 28

In this chapter, we will introduce the top-level circuit diagram of the proposed project
Early Detection of Brain Cancer Based on Artificial Intelligence. In Figure 4.1, shows
the circuit Model of the raspberry pi 4 image processor unit in which will be the
hardware that will be used to operate the image processing for classifying the brain
tumor.
4.2 Algorithms
This section will present the brain tumor detection Training for the different brain
tumor classification that used the Raspberry pi 4 image processing unit.

4.2.1 Training Algorithm


The algorithm of the Training Algorithm starts by:
• Importing library for Opencv and Tensorflow for build a CNN network.
• Mounting the drive and input the data that will be used to build the classifier CNN.
• Input the no of classes that will be used to identify the different brain tumor.
• Form the CNN network of the gathered data.

39
• Define the learning rate to build the classifier from 0.1 to 0.99
• Check the call back using the validation steps to get the accuracy of the CNN network
classifier.
o If the accuracy decreased, the algorithm loop back to get the new entered data
set.
o the accuracy increase as it is needed, the algorithm will plot confusion matric
for the CNN classifier.

Fig. 4.2: Training Algorithm 29

40
4.2.2 Detecting and Recognition Algorithm
The algorithm of the Detection and Recognition Algorithm starts by:
• Importing library for Opencv and Tensorflow to get the lite tensor flow pre trained
model.
• Importing the MRI image to the Raspberry pi 4.
• Then capture frame with RGB gripper to get the image from the MRI image without
coding for speed communication.
• Apply preprocessing for the MRI image lightening for better brightness and
contrast and apply auto encoder.
• Then the code will load the lite tensor flow pretrained model to classify the
brain tumor as an object.
• Then the system will decide either there are any brain tumor in the MRI image
is classified in the frame.
o If No, the system will loop back to get the image with different
preprocessing conditions.
o If Yes, the system will draw a bounding box for the Brain detected and
its type label with the percentage of true detection.
o Then the system will display this over the screen.
• Finally, the system will loop back again to continuously operate for multiple
MRI images.

41
Fig. 4.3: Detecting and Recognition Algorithm 30

4.3 Summary
This chapter presents the top level circuit for the image processing unit (Raspberry pi

42
4). Furthermore, the algorithm of Early Detection of Brain Cancer Based on Artificial
Intelligence is illustrated. The algorithm of Training algorithm and detecting
algorithm for Convolution Neural Network is illustrated and presented. The samples
of data used, results, and the software implemented will be presented in the next
chapter.

43
Chapter V
Implementation and Testing
5.1 Hardware implementation
Figure 5.1, shows the hardware implementation for our project Early Detection of
Brain Cancer Based on Artificial Intelligence prototype where it has compact size and
consume low energy. The Raspberry pi 4 will operate as separate computer board to
perform all the tasks for image processing and preprocessing algorithms as well as the
training and detection different brain tumor classifications.

Fig. 5.1: Hardware 31

5.1.2 Problem encountered


1- Collect 1000 MRI images for glioma_tumor
2- Collect 1000 MRI images for meningioma_tumor
3- Collect 1000 MRI images for pituitary_tumor.
4- Collect 1000 MRI images for No tumor.
5- Training large number of Brain Tumor classes.
7- Recognize the Brain Tumor types with high percentage over 90 %for true
detection.
5.2 Software implemented

5.2.1 Operating System on a Raspberry Pi


1-Download the distribution from the raspberrypi.org,

44
• Many operating systems are available to run on your Raspberry Pi. These include the
recommended Raspberry Pi OS (and its Lite alternative), Ubuntu, along with OSs for
Kodi, RetroPie, and many other projects.
2-Extract the image file
3-Insert the SD card into your SD card reader
4-Download the Raspberry Pi Imager utility
5-Extract the executable from the zip file and run the Raspberry Pi Imager utility
6-Select the image file you extracted above.

Fig. 5.2: Raspberry Pi Imager32

7-Click Write and wait for the write to complete.

Fig. 5.3: Select the OS33

8- Click Ctrl+Shift+X to preconfigure advanced options (see below)

45
9- Next, click Choose Storage to select the SD card
10- Click Write
11- With Raspberry Pi OS installed, you'll need to login with the following
credentials:
• Username: pi
• Password: pi
12-Updating and enabling Raspberry pi
13- Install Raspbian Bullseye linux operating system
14-sudo apt-get update
15-sudo apt-get upgrade
16-Coneccting through VNC viewer to the Rpi address.

Fig. 5.4: Raspberry Pi 4 OS view34

17- Setup the OpenCV over the Raspberry pi 4


• Sudo pip3 install opencv-python3

46
Fig. 5.5: OpenCV integrate with Python 335

18- Setup the Tensorflow over the Raspberry pi 4


• Sudo pip3 install tensorflow
• sudo apt-get install tensorflow

Fig. 5.6: TensorFlow integrate with Python 336

5.2.2 Brain Tumor Training


In this section we will demonstrate the training of several types of Brain tumour
types.
1- First step, gathering the dataset of the different brain tumour’s types after is scanned
and exported as MRI image (1000 for each type).

47
Fig. 5.7: Training images for different types of Brain tumors37

2- Then using the following packages for training the datastet.


3- Downloading Img Label and label each brain tumor type and create xml file for
training and test folders.

48
Fig. 5.8: Glioma Brain Tumor Manual Annotation example38

Fig. 5.9: Meningioma Brain Tumor Manual Annotation example39

49
Fig. 5.10: Pituitary Brain Tumor Manual Annotation example40

The above Figure 5.8, 5.9, and 5.10 shows the steps of training the different
three brain tumors (glioma, meningioma, pituitary) using label Image tool for
3000 MRI image dataset, then by using google colab we eill train over the
google drive to get the tensorflow model.
4- Then implement the packages over the board
pip install -q tflite-model-maker
pip install -q tflite-support
import numpy as np
import os
from tflite_model_maker.config import ExportFormat, QuantizationConfig
from tflite_model_maker import model_spec
from tflite_model_maker import object_detector
from tflite_support import metadata
import tensorflow as tf
assert tf.__version__.startswith('2')
tf.get_logger().setLevel('ERROR')
from absl import logging
logging.set_verbosity(logging.ERROR)
train_data = object_detector.DataLoader.from_pascal_voc(
'test1/train',
'test1/train',
[['glioma','meningioma','pituitary'])
val_data = object_detector.DataLoader.from_pascal_voc(
'test1/test',
'test1/test',
['glioma','meningioma','pituitary'])
spec = model_spec.get('efficientdet_lite0')
model = object_detector.create(train_data, model_spec=spec, batch_size=20,
train_whole_model=True, epochs=100, validation_data=val_data)
50
model.evaluate(val_data)

5- Then export the lite tensorflow lite model.


6- After exporting the model and change its setting, we will export the loss graph

Fig. 5.11: Loss Graph 41

Figure 5.11 demonstrate the loss graph for the training and validation loss over
different epochs, where it shows that the loss is decreasing over 15 epochs to 30
epochs, and we cannot increase more than to avoid over fitting lite tensor flow model.

7- After exporting the loss graph, we will export the accuracy graph

Fig. 5.12: Accuracy Graph 42

Figure 5.12 demonstrate the accuracy metrics graph for the training and validation
accuracy over different epochs, where it shows that the accuracy is increased over 20
epochs to 30 epochs, then the accuracy is increase and stabilized in the region over 20
51
to 30 epochs.

8- Finally, the confusion Matrix

Fig. 5.13: Confusion Matrix on Test set 43

In Figure 5.13 shows the confusion matrix using the trained and test folder for glioma,
meningioma, and pituitary brain tumor and shows high true detection with a zero false
detection between the different brain tumor classes.

5.2.2 Brain Tumor Recognition


In this section we will demonstrate the recognition of several types of Brain tumour
types.
1- Create a python file bc.py

import os
import torch
import cv2 as cv
import torch.nn as nn
import numpy as np
from PIL import Image
from torchvision import transforms, models
print('Library Importing....')
device_name = "cuda:0:" if torch.cuda.is_available() else "cpu"
device = torch.device(device_name)
print('Device Type....')
resnet_model = models.resnet50(pretrained=True)
for param in resnet_model.parameters():
param.requires_grad = True
n_inputs = resnet_model.fc.in_features
print('Model Loading ....')
resnet_model.fc = nn.Sequential(nn.Linear(n_inputs, 2048),

52
nn.SELU(),
nn.Dropout(p=0.4),
nn.Linear(2048, 2048),
nn.SELU(),
nn.Dropout(p=0.4),
nn.Linear(2048, 4),
nn.LogSigmoid())
for name, child in resnet_model.named_children():
for name2, params in child.named_parameters():
params.requires_grad = True
resnet_model.to(device)
#resnet_model.load_state_dict(torch.load('bt_resnet50_model.pt'))
resnet_model.load_state_dict(torch.load('bt_resnet50_model.pt',map_lo
cation ='cpu'))
print('Model Loaded')
resnet_model.eval()
transform = transforms.Compose([transforms.Resize((512, 512)),
transforms.ToTensor()])
LABELS = ['None', 'Meningioma', 'Glioma', 'Pitutary']
img_name = input("Enter path to the image: ")
if not os.path.exists(img_name):
print("File does not exits. Exiting...\n")
exit()
img = Image.open(img_name)
print('import test image')
img = transform(img)
img = img[None, ...]
print(device)
with torch.no_grad():
#y_hat = resnet_model.forward(img)
y_hat = resnet_model.forward(img.to(device))
print(y_hat)
predicted = torch.argmax(y_hat.data, dim=1)
print(LABELS[predicted.data],'\n')
img = Image.open(img_name)
Img = np.array(img)
curImg = np.array(img)
gray = cv.cvtColor(np.array(img), cv.COLOR_BGR2GRAY)
grayr = cv.resize(gray, (250, 250))
cv.imshow('Gray Image',grayr)
cv.waitKey(0)
ret, thresh = cv.threshold(gray, 0, 255, cv.THRESH_BINARY_INV +
cv.THRESH_OTSU)
kernel = np.ones((3, 3), np.uint8)
opening = cv.morphologyEx(thresh, cv.MORPH_OPEN, kernel,
iterations=2)
curImg = opening
curImgr = cv.resize(curImg, (250, 250))
cv.imshow('Negative Image',curImgr)
cv.waitKey(0)
# sure background area
sure_bg = cv.dilate(curImg, kernel, iterations=3)
# Finding sure foreground area
dist_transform = cv.distanceTransform(curImg, cv.DIST_L2, 5)
ret, sure_fg = cv.threshold(dist_transform, 0.7 *
dist_transform.max(), 255, 0)
# Find unknown region
sure_fg = np.uint8(sure_fg)
unknown = cv.subtract(sure_bg, sure_fg)
# Marker labelling
ret, markers = cv.connectedComponents(sure_fg)

53
# Add one to all labels so that sure background is not 0, but 1
markers = markers + 1
# Now mark the region of unknown with zero
markers[unknown == 255] = 0
markers = cv.watershed(Img, markers)
Img[markers == -1] = [255, 0, 0]
tumorImage = cv.cvtColor(Img, cv.COLOR_HSV2BGR)
tumorImager = cv.resize(tumorImage, (250, 250))
cv.imshow('Detected Region',tumorImager)
cv.waitKey(0)
curImg = tumorImage

2- Then we open the terminal


3- Write: cd nb
4- Then run the python code by: python3 bc.py

Fig. 5.14: Brain Tumour Recognition Result 1 44

Figure 5.14 results shows the output of the python code over terminal and images for
the original brain MRI, processed MRI image using edge detection, and the final
image with the region of the brain tumor. The result shows the importing of the
libraries, model, and the image needed to be analyzed (test1.jpg) and the output of
Meningioma with -0.1267 score. Also, the code successfully recognize the type and
the region of the brain tumor in approximately 213 ms.
Figure 5.15 results shows the output of the python code over terminal and images for
the original brain MRI, processed MRI image using edge detection, and the final
54
image with the region of the brain tumor. The result shows the importing of the
libraries, model, and the image needed to be analyzed (test2.jpg) and the output of
Meningioma with -0.4367 score. Also, the code successfully recognize the type and
the region of the brain tumor in approximately 228 ms.

Fig. 5.15: Brain Tumour Recognition Result 2 45

Fig. 5.16: Brain Tumour Recognition Result 3 46

55
Figure 5.16 results shows the output of the python code over terminal and images for
the original brain MRI, processed MRI image using edge detection, and the final
image with the region of the brain tumor. The result shows the importing of the
libraries, model, and the image needed to be analyzed (test3.jpg) and the output of
Pituitary with -3.2631 score. Also, the code successfully recognizes the type and the
region of the brain tumor in approximately 191 ms.

Fig. 5.17: Brain Tumour Recognition Result 4 47

Figure 5.17 results shows the output of the python code over terminal and images for
the original brain MRI, processed MRI image using edge detection, and the final
image with the region of the brain tumor. The result shows the importing of the
libraries, model, and the image needed to be analyzed (test4.jpg) and the output of
Pituitary with -0.0241 score. Also, the code successfully recognizes the type and the
region of the brain tumor in approximately 201 ms.
Figure 5.18 results shows the output of the python code over terminal and images for
the original brain MRI, processed MRI image using edge detection, and the final
image with the region of the brain tumor. The result shows the importing of the
libraries, model, and the image needed to be analyzed (test6.jpg) and the output of
Pituitary with -0.0594 score. Also, the code successfully recognizes the type and the
region of the brain tumor in approximately 214 ms.

56
Fig. 5.18: Brain Tumour Recognition Result 5 48

Fig. 5.19: Brain Tumour Recognition Result 6 49

Figure 5.19 results shows the output of the python code over terminal and images for
the original brain MRI, processed MRI image using edge detection, and the final
image with the region of the brain tumor. The result shows the importing of the
libraries, model, and the image needed to be analyzed (test7.jpg) and the output of

57
Glioma with -0.9454 score. Also, the code successfully recognizes the type and the
region of the brain tumor in approximately 232 ms.

Fig. 5.20: Brain Tumour Recognition Result 7 50

Figure 5.20 results shows the output of the python code over terminal and images for
the original brain MRI, processed MRI image using edge detection, and the final
image with the region of the brain tumor. The result shows the importing of the
libraries, model, and the image needed to be analyzed (test8.jpg) and the output of
Glioma with -1.1543 score. Also, the code successfully recognizes the type and the
region of the brain tumor in approximately 198 ms.
Figure 5.21 results shows the output of the python code over terminal and images for
the original brain MRI, processed MRI image using edge detection, and the final
image with the region of the brain tumor. The result shows the importing of the
libraries, model, and the image needed to be analyzed (test9.jpg) and the output of
Glioma with -0.4038 score. Also, the code successfully recognizes the type and the
region of the brain tumor in approximately 212 ms.

58
Fig. 5.21: Brain Tumour Recognition Result 8 51

Fig. 5.22: Brain Tumour Recognition Result 9 52

Figure 5.22 results shows the output of the python code over terminal and images for
the original brain MRI, processed MRI image using edge detection, and the final
image with the region of the brain tumor. The result shows the importing of the
libraries, model, and the image needed to be analyzed (test10.jpg) and the output of

59
Meningioma with -0.07192 score. Also, the code successfully recognizes the type and
the region of the brain tumor in approximately 199 ms.

Fig. 5.23: Brain Tumour Recognition Result 10 53

Fig. 5.24: Brain Tumour Recognition Result 11 54

Figure 5.23 results shows the output of the python code over terminal and images for
the original brain MRI, processed MRI image using edge detection, and the final
image with the region of the brain tumor. The result shows the importing of the
60
libraries, model, and the image needed to be analyzed (test11.jpg) and the output of
Meningioma with -0.04428 score. Also, the code successfully recognizes the type and
the region of the brain tumor in approximately 211 ms.
Figure 5.24 results shows the output of the python code over terminal and images for
the original brain MRI, processed MRI image using edge detection, and the final
image with the region of the brain tumor. The result shows the importing of the
libraries, model, and the image needed to be analyzed (test12.jpg) and the output of
Meningioma with -5.9e-3 score. Also, the code successfully recognizes the type and
the region of the brain tumor in approximately 210 ms.

Fig. 5.25: Brain Tumour Recognition Result 12 55

Figure 5.25 results shows the output of the python code over terminal and images for
the original brain MRI, processed MRI image using edge detection, and the final
image with the region of the brain tumor. The result shows the importing of the
libraries, model, and the image needed to be analyzed (test14.jpg) and the output of
Glioma with -3.2759 score. Also, the code successfully recognizes the type and the
region of the brain tumor in approximately 221 ms. Finally it shows the region of the
tumor with extreme color mapping showing the enlargement part of the Glioma brain
tumor.

61
Chapter VI
COST ANALYSIS
Table 6.1 Cost Analysis4

Item Cost
Raspberry Pi 4 3000
Total 3000

62
Chapter VII
TIME PLAN

Table 7.1 Time Plan5

Task Task
Task Description Exact Execution Time
No. Holder
1 Micheal Installing tensorflow over Python 2 weeks
2 Saad Installing Pytorch over Python 2 weeks
3 Micheal Glioma Brain tumor Training 1 week
4 Saad Meningioma Brain Tumor Training 1 week
5 Micheal Pituitary Brain Tumor Training 2 weeks
6 Saad Testing by detecting MRI 2 weeks
Micheal Final Preparation 1 week
7
Saad

63
Chapter VIII
CONCLUSION AND FUTURE WORK
8.1 Conclusion
Image segmentation plays a significant role in medical image processing as medical
images have different diversities. For brain tumor segmentation, we used MRI and CT
scan images. MRI is most vastly used for brain tumor segmentation and classification.
In this project, clustering for tumor segmentation which can predict tumor cells
accurately. The segmentation process was followed by classification using traditional
classifiers and Convolutional Neural Network. In the traditional classifier part, then
the results will be applied and compared to different traditional classifiers such as K-
Nearest Neighbor, Logistic Regression, Multilayer Perceptron, Naïve Bayes, Random
Forest, and Support Vector Machine
Further, for better results, we will implement CNN to achieve high accuracy above
97.87% with a split ratio of 80:20 of 50 images, i.e. 80% of training images and 20%
of testing images.

64
8.2 Future Work

The Early Detection of Brain Cancer Based on Artificial Intelligence can be upgraded
by using the following operations:

• Using higher CPU units to increase the performance of detection

• Increasing the performance of the graphical processing unit.

• Train new brain tumor types to detect more tumor objects

• Adding more MRI images for eah class for better detection and recognition.

• Making a website that the user upload the MRI to get the results over the
internet without any delivery.

• Apply the project to differentiate between brain tumor and other brain
diseases.

65
References
[1] Kasban, Hany & El-bendary, Mohsen & Salama, Dina. (2015). “A Comparative
Study of Medical Imaging Techniques”. International Journal of Information
Science and Intelligent System. 4. 37-58.J. Clerk Maxwell, A Treatise on
Electricity and Magnetism, 3rd ed., vol. 2. Oxford: Clarendon, 1892, pp.68–73.
[2] D. Surya Prabha and J. Satheesh Kumar, “Performance Evaluation of Image
Segmentation using Objective Methods”, Indian Journal of Science and
Technology, Vol 9(8), February 2016.
[3] Brain Tumor: Statistics, Cancer.Net Editorial Board, 11/2017 (Accessed on 17th
January 2019)
[4] Kavitha Angamuthu Rajasekaran and Chellamuthu Chinna Gounder, Advanced
Brain Tumour Segmentation from MRI Images, 2018.
[5] General Information About Adult Brain Tumors". NCI. 14 April 2014. Archived
from the original on 5 July 2014. Retrieved 8 June 2014. (Accessed on 11th
January 2019)
[6] M. Young, The Technical Writer’s Handbook. Mill Valley, CA: University
Science, 1989.
[7] K. Bhagwat, D. More, S. Shinde, A. Daga, Assistant Prof. Rupali Tornekar, “
Comparative Study Of Brain Tumor Detection Using K Means ,Fuzzy C Means
And Hierarchical Clustering Algorithms ” International Journal Of Scientific &
Engineering Research , Volume 2, Issue 6, June 2013, 626-632.
[8] A. Sivaramakrishnan And M. Karnan “A Novel Based Approach For Extraction
Of Brain Tumor In MRI Images Using Soft Computing Techniques”,
International Journal Of Advanced Research In Computer And Communication
Engineering, Vol. 2, Issue 4, April 2013.
[9] S. Roy And S. K. Bandoyopadhyay, “Detection And Qualification Of Brain
Tumor From Mri Of Brain And Symmetric Analysis”, International Journal Of
Information And Communication Technology Research, Volume 2 No.6, June
2012, 584-588.
[10] H. Zhang, J. E. Fritts, S. A. Goldman,“Image Segmentation Evaluation: A
Survey Of Unsupervised Methods”, Computer Vision And Image
Understanding, Pp. 260-280, 2008.

66
[11] W. Liu, D. Anguelov, D. Erhan, C. Szegedy, S. Reed, C.-Y. Fu, and A. C. Berg,
“Ssd: Single shot multibox detector,” in European conference on computer
vision. Springer, 2016, pp. 21–37.
[12] B. Patenaude, S. M. Smith, D. N. Kennedy, and M. Jenkinson, “A bayesian
model of shape and appearance for subcortical brain segmentation,”
Neuroimage, vol. 56, no. 3, pp. 907–922, 2011.
[13] A. de Brebisson and G. Montana, “Deep neural networks for anatomical brain
segmentation,” in Proceedings of the IEEE Conference on Computer Vision and
Pattern Recognition Workshops, 2015, pp. 20–28.
[14] M. Ghafoorian, N. Karssemeijer, T. Heskes, M. Bergkamp, J. Wissink, J. Obels,
K. Keizer, F.-E. de Leeuw, B. van Ginneken, E. Marchiori et al., “Deep multi-
scale location-aware 3d convolutional neural networks for automated detection
of lacunes of presumed vascular origin,” NeuroImage: Clinical, vol. 14, pp. 391–
399, 2017.
[15] Q. Dou, H. Chen, L. Yu, L. Zhao, J. Qin, D. Wang, V. C. Mok, L. Shi, and P.-A.
Heng, “Automatic detection of cerebral microbleeds from mr images via 3d
convolutional neural networks,” IEEE transactions on medical imaging, vol. 35,
no. 5, pp. 1182–1195, 2016.
[16] Q. Dou, H. Chen, L. Yu, L. Shi, D. Wang, V. C. Mok, and P. A. Heng,
“Automatic cerebral microbleeds detection from mr images via independent
subspace analysis based hierarchical features,” in Engineering in Medicine and
Biology Society (EMBC), 2015 37th Annual International Conference of the
IEEE. IEEE, 2015, pp. 7933– 7936.
[17] H.-I. Suk, C.-Y. Wee, S.-W. Lee, and D. Shen, “State-space model with deep
learning for functional dynamics estimation in resting-state fmri,” NeuroImage,
vol. 129, pp. 292–307, 2016.
[18] H.-I. Suk and D. Shen, “Deep ensemble sparse regression network for
alzheimers disease diagnosis,” in International Workshop on Machine Learning
in Medical Imaging. Springer, 2016, pp. 113–121.
[19] W. H. Pinaya, A. Gadelha, O. M. Doyle, C. Noto, A. Zugman, Q. Cordeiro, A.
P. Jackowski, R. A. Bressan, and J. R. Sato, “Using deep belief network
modelling to characterize differences in brain morphometry in schizophrenia,”
Scientific reports, vol. 6, p. 38897, 2016.

67
[20] Y. Yoo, L. W. Tang, T. Brosch, D. K. Li, L. Metz, A. Traboulsee, and R. Tam,
“Deep learning of brain lesion patterns for predicting future disease activity in
patients with early symptoms of multiple sclerosis,” in Deep Learning and Data
Labeling for Medical Applications. Springer, 2016, pp. 86–94.
[21] H. K. van der Burgh, R. Schmidt, H.-J. Westeneng, M. A. de Reus, L. H. van
den Berg, and M. P. van den Heuvel, “Deep learning predictions of survival
based on mri in amyotrophic lateral sclerosis,” NeuroImage: Clinical, vol. 13,
pp. 361–369, 2017.
[22] D. Zikic, Y. Ioannou, M. Brown, and A. Criminisi, “Segmentation of brain
tumor tissues with convolutional neural networks,” Proceedings MICCAI-
BRATS, pp. 36–39, 2014.
[23] G. Urban, M. Bendszus, F. Hamprecht, and J. Kleesiek, “Multi-modal brain
tumor segmentation using deep convolutional neural networks,” MICCAI BraTS
(Brain Tumor Segmentation) Challenge. Proceedings, winning contribution, pp.
31–35, 2014.
[24] J. Long, E. Shelhamer, and T. Darrell, “Fully convolutional networks for
semantic segmentation,” in Proceedings of the IEEE conference on computer
vision and pattern recognition, 2015, pp. 3431–3440.
[25] O. Ronneberger, P. Fischer, and T. Brox, “U-net: Convolutional networks for
biomedical image segmentation,” in International Conference on Medical image
computing and computer-assisted intervention. Springer, 2015, pp. 234–241.
[26] G. Wang, W. Li, S. Ourselin, and T. Vercauteren, “Automatic brain tumor
segmentation using cascaded anisotropic convolutional neural networks,” in
International MICCAI Brainlesion Workshop. Springer, 2017, pp. 178–190.
[27] A. Graves and J. Schmidhuber, “Offline handwriting recognition with
multidimensional recurrent neural networks,” in Advances in neural information
processing systems, 2009, pp. 545–552.
[28] W. Byeon, T. M. Breuel, F. Raue, and M. Liwicki, “Scene labeling with lstm
recurrent neural networks,” in Proceedings of the IEEE Conference on Computer
Vision and Pattern Recognition, 2015, pp. 3547–3555.
[29] I. Goodfellow, J. Pouget-Abadie, M. Mirza, B. Xu, D. Warde-Farley, S. Ozair,
A. Courville, and Y. Bengio, “Generative adversarial nets,” in Advances in
neural information processing systems, 2014, pp. 2672–2680.

68
[30] P. Luc, C. Couprie, S. Chintala, and J. Verbeek, “Semantic segmentation using
adversarial networks,” in NIPS Workshop on Adversarial Training, 2016.
[31] X. Chen, N. Pawlowski, M. Rajchl, B. Glocker, and E. Konukoglu, “Deep
generative models in the real-world: An open challenge from medical imaging,”
arXiv preprint arXiv:1806.05452, 2018.
[32] Best Artificial Intelligence Boards and Single Computer Board, Electro Maker
articles, 2021 https://www.electromaker.io/blog/article/best-sbc-for-ai-single-
board-computer-for-artificial-intelligence.

69
70
‫الملخص‬

‫تم توثيق أكثر من ‪ 150‬نوعًا من أورام المخ على أساس الخصائص النسيجية المرضية‪ .‬يعد تجزئة ورم الدماغ‬
‫أحد أكثر المهام أهمية وشاقة في مجال معالجة الصور الطبية حيث يمكن أن يؤدي التصنيف اليدوي بمساعدة‬
‫اإلنسان إلى التنبؤ والتشخيص غير الدقيقين‪ .‬عالوة على ذلك ‪ ،‬إنها مهمة مشددة عندما يكون هناك كمية كبيرة‬
‫من البيانات للمساعدة‪ .‬تتميز أورام الدماغ بتنوع كبير في المظهر وهناك تشابه بين الورم واألنسجة الطبيعية ‪،‬‬
‫وبالتالي فإن استخراج مناطق الورم من الصور يصبح صعبًا‪.‬‬

‫يشير التصوير الطبي إلى عدد من التقنيات التي يمكن استخدامها كوسائل غير جراحية للنظر داخل الجسم‪ .‬تشمل‬
‫الصورة الطبية طرائق وعمليات صور مختلفة لتصوير جسم اإلنسان ألغراض العالج والتشخيص ‪ ،‬وبالتالي‬
‫دورا أساسيًا وحاس ًما في اتخاذ اإلجراءات لتحسين صحة الناس‪.‬‬
‫تلعب ً‬

‫يعد تجزئة الصورة خطوة حاسمة وأساسية في معالجة الصور والتي تحدد نجاح مستوى أعلى من معالجة‬
‫الصور‪ .‬الهدف األساسي من تجزئة الصورة في معالجة الصور الطبية هو بشكل أساسي الكشف عن الورم أو‬
‫اآلفات ‪ ،‬والرؤية الفعالة لآللة وتحقيق نتيجة مرضية لمزيد من التشخيص‪ .‬أصبح تحسين حساسية ونوعية الورم‬
‫أو اآلفة مشكلة أساسية في الصور الطبية بمساعدة أنظمة التشخيص بمساعدة الكمبيوتر (‪.)CAD‬‬

‫في هذا المشروع ‪ ،‬يتم استخدام طريقة مقترحة الستخراج ورم الدماغ من صور الدماغ بالرنين المغناطيسي‬
‫ثنائي األبعاد (‪ ) MRI‬بواسطة خوارزمية الشبكة العصبية االلتفافية والتي أعقبتها المصنفات التقليدية والشبكة‬
‫العصبية التالفيفية‪ .‬سي تم إجراء الدراسة التجريبية على مجموعة بيانات في الوقت الفعلي مع أحجام ورم متنوعة‬
‫ومواقع وأشكال وكثافة مختلفة للصورة‪ .‬في جزء المصنف التقليدي ‪ ،‬سيتم تطبيقه على ستة مصنفات تقليدية‬
‫وهي‪ :‬آلة المتجهات الداعمة ( )‪ ، )K-Nearest Neighbor (KNN ،SVM‬متعدد الطبقات ‪Perceptron‬‬
‫‪ ، )(MLP‬االنحدار اللوجستي ‪ Naïve Bayes ،‬و ‪ Random Forest‬التي تم تنفيذها في ‪. scikit-Learn‬‬
‫بعد ذلك ‪ ،‬سيتم تنفيذ الشبكة العصبية التالفيفية (‪ )CNN‬باستخدام ‪ Keras‬و ‪ Tensorflow‬ألنها تؤدي إلى أداء‬
‫أفضل من تلك التقليدية‪.‬‬
‫جامعة أكتوبر للعلوم الحديثة واآلداب‬
‫كلية الهندسة‬

‫قسم هندسة نظم االتصاالت و االلكترونيات‬

‫أنظمه الكشف المبكر لسرطان المخ باالعتماد على‬


‫الذكاء االصطناعي‬
‫مشروع التخرج‬
‫قدم ضمن متطلبات درجة البكالوريوس فى الهندسة الكهربية والحاسبات‬
‫الجزء الثانى‬

‫إعداد‬
‫سعد محمد سعد ابوفرو‬
‫مايكل نبيل سالمة ذكي‬

‫إشراف‬
‫د‪/‬محمد سعيد‬

‫‪2023-2022‬‬

You might also like