which technique used in the preprocessing ?
Show older comments
main.m file
clc;
clear all;
close all;
while(1)
ch = menu('BRAIN TUMOUR SEGMENTATION','Input Image','Preprocessing','Feature Extraction','Segmentation','Exit');
if(ch==1)
[I,path]=uigetfile('*.jpg','select a input image');
str=strcat(path,I);
s=imread(str);
figure,imshow(s),title('Input image');
[m1 m2 m3]=size(s);
end
if(ch==2)
num_iter = 10;
delta_t = 1/7;
kappa = 15;
option = 1;
ede=im2bw(s);
imie=edge(ede,'canny');
disp('Preprocessing image please wait . . .');
ad = process(s,num_iter,delta_t,kappa,option);
adj = uint8(ad);
figure,
subplot 121, imshow(s,[]),title('Input image');
subplot 122, imshow(adj,[]),title('Filtered image');
end
process.m file
function diff_im = process(im, num_iter, delta_t, kappa, option)
persistent cN cS cW cE cNE cSE cNW cSW;
cN = double(0);
cS = double(0);
cW = double(0);
cE = double(0);
cNE = double(0);
cSE = double(0);
cNW = double(0);
cSW = double(0);
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
fprintf('Removing noise\n');
fprintf('Filtering Completed !!\n');
% Convert input image to double.
im = double(im);
% PDE (partial differential equation) initial condition.
diff_im = im;
% Center pixel distances.
dx = 1;
dy = 1;
dd = sqrt(2);
% 2D convolution masks - finite differences.
hN = [0 1 0; 0 -1 0; 0 0 0];
hS = [0 0 0; 0 -1 0; 0 1 0];
hE = [0 0 0; 0 -1 1; 0 0 0];
hW = [0 0 0; 1 -1 0; 0 0 0];
hNE = [0 0 1; 0 -1 0; 0 0 0];
hSE = [0 0 0; 0 -1 0; 0 0 1];
hSW = [0 0 0; 0 -1 0; 1 0 0];
hNW = [1 0 0; 0 -1 0; 0 0 0];
for t = 1:num_iter
% Finite differences. [imfilter(.,.,'conv') can be replaced by conv2(.,.,'same')]
nablaN = imfilter(diff_im,hN,'conv');
nablaS = imfilter(diff_im,hS,'conv');
nablaW = imfilter(diff_im,hW,'conv');
nablaE = imfilter(diff_im,hE,'conv');
nablaNE = imfilter(diff_im,hNE,'conv');
nablaSE = imfilter(diff_im,hSE,'conv');
nablaSW = imfilter(diff_im,hSW,'conv');
nablaNW = imfilter(diff_im,hNW,'conv');
% 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
% Discrete PDE solution.
diff_im = diff_im + delta_t*((1/(dy^2))*cN.*nablaN + (1/(dy^2))*cS.*nablaS +(1/(dx^2))*cW.*nablaW +(1/(dx^2))*cE.*nablaE +(1/(dd^2))*cNE.*nablaNE + (1/(dd^2))*cSE.*nablaSE +(1/(dd^2))*cSW.*nablaSW + (1/(dd^2))*cNW.*nablaNW );
end
end
Answers (0)
Categories
Find more on Hypothesis Tests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!