DSP PBL
DSP PBL
Images.
Aim: To find tumor of given MRI image by using matlab s/w
Equipment Required: Computer with pre loaded OS and Matlab 2016b software version
software with image processing tool box
ABSTRACT
Brain Tumor is a fatal disease which cannot be confidently detected without MRI. In the project,
it is tried to detect whether patient’s brain has tumor or not from MRI image using MATLAB
simulation.
To pave the way for morphological operation on MRI image, the image was first filtered using
Anisotropic Diffusion Filter to reduce contrast between consecutive pixels. After that the image
was resized and utilizing a threshold value image was converted to a black and white image
manually. This primary filters the plausible locations for tumor presence.
On this semi processed image morphological operations have been applied and information on
solidity and areas of the plausible locations was obtained. A minimum value of both of these
characters has been determined from statistical average of different MRI images containing
tumor. Then it was used to deliver final detection result.
Though this simulation routine can give correct result most of the time, it fails to perform when
tumor’s size is too small or tumor is hollow.
The larger goal of the project is to build a data base of 2D image data of tumor from the MRI
images taken from different angle of a particular human and by analyzing them to point out the
exact 3D location of the tumor . To fulfill this, 2D tumor detection and segmentation have been
developed to better accuracy so that 3D detection can be more reliable. This is the primary target
of the project.
Function:
% Anisotropic diffusion.
for t = 1:num_iter
% Diffusion function.
if option == 1
cN = exp(-(nablaN/kappa).^2);
cS = exp(-(nablaS/kappa).^2);
cW = exp(-(nablaW/kappa).^2);
cE = exp(-(nablaE/kappa).^2);
cNE = exp(-(nablaNE/kappa).^2);
cSE = exp(-(nablaSE/kappa).^2);
cSW = exp(-(nablaSW/kappa).^2);
cNW = exp(-(nablaNW/kappa).^2);
elseif option == 2
cN = 1./(1 + (nablaN/kappa).^2);
cS = 1./(1 + (nablaS/kappa).^2);
cW = 1./(1 + (nablaW/kappa).^2);
cE = 1./(1 + (nablaE/kappa).^2);
cNE = 1./(1 + (nablaNE/kappa).^2);
cSE = 1./(1 + (nablaSE/kappa).^2);
cSW = 1./(1 + (nablaSW/kappa).^2);
cNW = 1./(1 + (nablaNW/kappa).^2);
end
clc
close all
clear all
%% Input
[I,path]=uigetfile('*.jpg','select a input image');
str=strcat(path,I);
s=imread(str);
figure;
imshow(s);
title('Input image','FontSize',20);
%% Filter
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
figure;
imshow(inp);
title('Filtered image','FontSize',20);
%% thresholding
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
%% Morphological Operation
label=bwlabel(sout);
stats=regionprops(logical(sout),'Solidity','Area','BoundingBox');
density=[stats.Solidity];
area=[stats.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
figure;
imshow(tumor)
title('tumor alone','FontSize',20);
else
h = msgbox('No Tumor!!','status');
%disp('no tumor');
return;
end
%% Bounding box
box = stats(tumor_label);
wantedBox = box.BoundingBox;
figure
imshow(inp);
title('Bounding Box','FontSize',20);
hold on;
rectangle('Position',wantedBox,'EdgeColor','y');
hold off;
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
figure
imshow(erodedImage);
title('eroded image','FontSize',20);
%% subtracting eroded image from original BW image
tumorOutline=tumor;
tumorOutline(erodedImage)=0;
figure;
imshow(tumorOutline);
title('Tumor Outline','FontSize',20);
tumorOutlineInserted(:,:,1) = red;
tumorOutlineInserted(:,:,2) = green;
tumorOutlineInserted(:,:,3) = blue;
figure
imshow(tumorOutlineInserted);
title('Detected Tumer','FontSize',20);
%% Display Together
figure
subplot(231);imshow(s);title('Input image','FontSize',20);
subplot(232);imshow(inp);title('Filtered image','FontSize',20);
subplot(233);imshow(inp);title('Bounding Box','FontSize',20);
hold on;rectangle('Position',wantedBox,'EdgeColor','y');hold off;
subplot(234);imshow(tumor);title('tumor alone','FontSize',20);
subplot(235);imshow(tumorOutline);title('Tumor Outline','FontSize',20);
subplot(236);imshow(tumorOutlineInserted);title('Detected
Tumor','FontSize',20);
Data base:
Results: Hence, I observed Brain Tumor Detection and Segmentation from MRI
Images by using matlab software.