Brain Tumor Detection
Brain Tumor Detection
Engineers have been actively developing tools to detect tumors and to process
medical images. Medical image segmentation is a powerful tool that is often
used to detect tumors. Many scientists and researchers are working to develop
and add more features to this tool. This project is about detecting Brain tumors
from MRI images using an interface of GUI in Matlab. Using the GUI, this
program can use various combinations of segmentation, filters, and other
image processing algorithms to achieve the best results. We start with filtering
the image using Prewitt horizontal edge-emphasizing filter. The next step for
detecting tumor is "watershed pixels." The most important part of this project
is that all the Matlab programs work with GUI “Matlab guide”. This allows us to
use various combinations of filters, and other image processing techniques to
arrive at the best result that can help us detect brain tumors in their early
stages.
Introduction:
We also created a gui so that it shows different stages of the tumor detection.
Medical image processing is the most challenging and emerging field now a
days. Processing of MRI images is one of the part of this field. This code makes
MRI image analysis accessible to more people who need not have to be
specialist on MRI imaging.
MRI imaging is less harmful than X-ray . It is less attenuated by bones. This
project can make MRI image processing and tumor detection process faster
and cheaper.
1. http://stackexchange.com/
2. https://www.mathworks.com/matlabcentral/fileexchange/55107-brain-
mri-tumor-detection-and-classification
3. http://researchgate.in/ “perona malik” research paper.
4. https://itk.org/ITKExamples/src/Filtering/AnisotropicSmoothing/Compute
PeronaMalikAnisotropicDiffusion/Documentation.html
5. http://www.ijircce.com/upload/2017/march/293_An_Efficient.pdf
About project:
Algorithm:
Prerequisites:
Mean
Mean is most basic of all statistical measure. Means are often used in
geometry and analysis; a wide range of means have been developed for these
purposes. In contest of image processing filtering using mean is classified as
spatial filtering and used for noise reduction. In this section we have discussed
about various type of mean and analysed their use for removing various type
of noise in image processing.
Arithmetic Mean
The arithmetic mean filter [2], also known as averaging filter, operates
on an sliding ‘m×n’ window by calculating the average of all pixel values
within the window and replacing the center pixel value in the
destination image with the result. Its mathematical formulation is given
as follows
Where ‘g’ is the noisy image, f(x,y) is the restored image, and ‘r’ and ‘c’
are the row and column coordinates respectively, within a window ‘W’
of size ‘m×n’ where the operation takes place.The arithmetic mean filter
causes a certain amount of blurring (proportional to the window size) to
the image, thereby reducing the effects of noise and local variations. It
can be used to reduce noise of different types, but works best for
Gaussian, uniform, or Erlang noise. Fig. 2 (C) shows the image after
arithmetic mean filtering of Gaussian noise added image.
STANDARD DEVIATION
The variance
It is a measure of how far a set of numbers is spread out. It is one of
several descriptors of a probability distribution, describing how far the
numbers lie from the mean (expected value). In particular, the variance
is one of the moments of a distribution. In that context, it forms part of a
systematic approach to distinguishing between probability distributions.
While other such approaches have been developed, those based on
moments are advantageous in terms of mathematical and
computational simplicity. Mathematically variance is given by
SKEWNESS
In statistics, skewness [8] is a measure of the asymmetry of the
probability distribution of a real-valued random variable. The skewness
value can be positive or negative, or even undefined. Qualitatively, a
negative skew indicates that the tail on the left side of the probability
density function is longer than the right side and the bulk of the values
(possibly including the median) lie to the right of the mean. A positive
skew indicates that the tail on the right side is longer than the left side
and the bulk of the values lie to the left of the mean. A zero value
indicates that the values are relatively evenly distributed on both sides
of the mean, typically but not necessarily implying a symmetric
distribution. Mathematically skewness can be given by
Figure:
Of the image.
The comparisons which are necessary to identify the tumor. We have given the
function such that if the area is lass than 100 mm sq , it neglects the tumor. It
also neglects if the density is less than 0.6 g/cc .
The function is designed such that depending on the tumor size it will be
highlighted in three different colors.
Even there are parameters of tumor like skewness , mean , variance standard
deviation etc.
The function is developed such that if there is no tumor in the given mri it will
stop execution of the further function after implementing anisotropic diffusion
filter part. Library functions for morphological operation were used to segment
the binary image & detect the tumor area.The Binary image was eroded, i.e, all
the points in the neighborhood of a black point was turned black. Finally we get
the border by subtracting the eroded image from original binary image.
num_iter=10;
delta_t = 1/7;
kappa = 15;
option = 2;
disp('Preprocessing image please wait . . .');
inp = anisodiff(s,num_iter,delta_t,kappa,option);
inp = uint8(inp);
inp=imresize(inp,[256,256]);
if size(inp,3)>1
inp=rgb2gray(inp);
end
axes(handles.axes2)
imshow(inp)
title('Filtered image','FontSize',10);
sout=imresize(inp,[256,256]);
t0=60;
th=t0+((max(inp(:))+min(inp(:)))./2);
for i=1:1:size(inp,1)
for j=1:1:size(inp,2)
if inp(i,j)>th
sout(i,j)=1;
else
sout(i,j)=0;
end
end
end
label=bwlabel(sout);
stats=regionprops(logical(sout),'Solidity','Area','Boundi
ngBox');
density=[stats.Solidity];
disp("density:")
area=[stats.Area];
disp("area:")
high_dense_area=density>0.6;
max_area=max(area(high_dense_area));
tumor_label=find(area==max_area);
tumor=ismember(label,tumor_label);
if max_area>100
axes(handles.axes4);
imshow(tumor)
title('tumor alone','FontSize',10);
else
h = msgbox('No Tumor!!','status');
% disp('no tumor');
return;
end
box = stats(tumor_label);
wantedBox = box.BoundingBox;
axes(handles.axes3);
imshow(inp);
title('Bounding Box','FontSize',10);
rectangle('Position',wantedBox,'EdgeColor','y');
dilationAmount = 5;
rad = floor(dilationAmount);
[r,c] = size(tumor);
filledImage = imfill(tumor, 'holes');
for i=1:r
for j=1:c
x1=i-rad;
x2=i+rad;
y1=j-rad;
y2=j+rad;
if x1<1
x1=1;
end
if x2>r
x2=r;
end
if y1<1
y1=1;
end
if y2>c
y2=c;
end
erodedImage(i,j) =
min(min(filledImage(x1:x2,y1:y2)));
end
end
tumorOutline=tumor;
tumorOutline(erodedImage)=0;
axes(handles.axes5)
imshow(tumorOutline)
title('Tumor Outline','FontSize',10);
rgb = inp(:,:,[1 1 1]);
red = rgb(:,:,1);
red(tumorOutline)=255;
green = rgb(:,:,2);
green(tumorOutline)=255;
blue = rgb(:,:,3);
blue(tumorOutline)=255;
tumorOutlineInserted(:,:,1) = red;
tumorOutlineInserted(:,:,2) = green;
tumorOutlineInserted(:,:,3) = blue;
axes(handles.axes6)
imshow(tumorOutlineInserted)
%img2=tumoroutlineinserted;
img2=im2bw(s);
title('Detected Tumor','FontSize',15);
handles.imgdata2=img2;
guidata(hObject,handles);
signal1=img2(:,:);
[cA1,~,~,~] = dwt2(signal1,'db4');
[cA2,~,~,~] = dwt2(cA1,'db4');
[cA3,cH3,cV3,cD3] = dwt2(cA2,'db4');
DWT_feat = [cA3,cH3,cV3,cD3];
G = pca(DWT_feat);
whos DWT_feat
whos G
g = graycomatrix(G);
stats = graycoprops(g,'Contrast Correlation Energy
Homogeneity');
Contrast = stats.Contrast;
Correlation = stats.Correlation;
Energy = stats.Energy;
Homogeneity = stats.Homogeneity;
Mean = mean2(G);
Standard_Deviation = std2(G);
Variance = mean2(var(double(G)));
Skewness = skewness(double(G(:)));
set(handles.edit1,'string',Mean);
set(handles.edit2,'string',Standard_Deviation);
set(handles.edit3,'string',Variance);
set(handles.edit4,'string',Skewness);
set(handles.edit5,'string',Contrast);
set(handles.edit6,'string',Correlation);
Results:
If there is a tumor
If there no tumor
Observations:
Challenges:
Scope of improvement:
We see that using the GUI based program, we obtain far superior
results than the traditional techniques for tumor detection. Using the
GUI based programs allows us to change the parameters without
rewriting the program and allows fast and efficient detection of
tumors. The results are clearly more accurate and faster.