Effacer les filtres
Effacer les filtres

I have attached my code , in the classification section , I am only getting epidural image and other type of haemorhage is not getting classified. Please can you help

1 vue (au cours des 30 derniers jours)
if true
% code
end
%%Image Acquisition %%
[Filename ,Pathname] = uigetfile('Extra Axial Haemorrhage\*.*','Select One Input Image'); I = imread([Pathname Filename]); save Filename Filename
figure('Name','Input Image','NumberTitle','Off'); imshow(I); axis off; title('Input Image','fontsize',12,'fontname','Times New Roman','color','Black');
I = imresize(I,[256 256]); [m,n,ch] = size(I); if ch==3 I = rgb2gray(I); end figure('Name','Resized Image','NumberTitle','Off'); imshow(I); axis off; title('Resized Image','fontsize',12,'fontname','Times New Roman','color','Black');
%% Preprocessing %%
% Power law transformation %
I_temp = double(I); c = 1; %constant gamma = 0.8; I_plt = c*I_temp.^gamma ; figure,imshow(I_plt, []);title('Power Law transformation');
%% Segmentation %%
% Sobel %
% img=imread('a.jpg'); % B=rgb2gray(img); % subplot(2,2,1) % imshow(B) % pause(2)
% Sobel Power Law Transformation % I_sobelplt = double(I_plt);
for i=1:size(I_sobelplt,1)-2 for j=1:size(I_sobelplt,2)-2 %Sobel mask for x-direction: mx=((2*I_sobelplt(i+2,j+1)+I_sobelplt(i+2,j)+I_sobelplt(i+2,j+2))-(2*I_sobelplt(i,j+1)+I_sobelplt(i,j)+I_sobelplt(i,j+2))); %Sobel mask for y-direction:m my=((2*I_sobelplt(i+1,j+2)+I_sobelplt(i,j+2)+I_sobelplt(i+2,j+2))-(2*I_sobelplt(i+1,j)+I_sobelplt(i,j)+I_sobelplt(i+2,j)));
I_plt(i,j)=sqrt(mx.^2+my.^2); end end % subplot(2,2,2) %figure,imshow(I_plt); title('Sobel gradient'); %pause(2) %Define a threshold value %Entropy_Iplt = entropy(I_plt);
Thresh=100; I_plt=max(I_plt,Thresh); I_plt(I_plt==round(Thresh))=0; I_plt=uint8(I_plt);
%subplot(2,2,3) figure,imshow(~I_plt);title('PLT Sobel edge detection');
% Prewitt %
% Prewitt PLT %
I_prplt = edge(I_plt,'prewitt'); figure,imshow(I_prplt);title('PLT Prewitt Edge detected Image');
% Canny %
% Canny PLT %
I_cplt = edge(I_plt,'Canny');
figure('Name','Segmentation Process','NumberTitle','Off'); imshow(I_cplt); axis off; title('PLT Canny Edge Detector','fontsize',12,'fontname','Times New Roman','color','Black');
% Gaussian Filter %
% Gaussian Filter PLT %
H = fspecial('gaussian',[3 3],0.5); Gaussian_Filt = imfilter(I_plt,H,'replicate');
figure('Name','Preprocessing Image','NumberTitle','Off'); imshow(Gaussian_Filt); axis off; title('Gaussian Filtering ','fontsize',12,'fontname','Times New Roman','color','Black');
Igray = Gaussian_Filt;
I_gplt = double(Igray); classType = class(Igray); scalingFactor = double(intmax(classType)); I_gplt = I_gplt/scalingFactor; Gx = [-1 1]; Gy = Gx'; Ix = conv2(I_gplt,Gx,'same'); Iy = conv2(I_gplt,Gy,'same');
figure('Name','Ix','NumberTitle','Off'); imshow(Ix ,[]); axis off; title('Ix_plt','fontsize',12,'fontname','Times New Roman','color','Black');
figure('Name','Iy','NumberTitle','Off'); imshow(Iy ,[]); axis off; title('Iy_plt','fontsize',12,'fontname','Times New Roman','color','Black');
% Fuzzy %
% Fuzzy PLT %
edgeFIS = newfis('edgeDetection'); edgeFIS = addvar(edgeFIS,'input','Ix ',[-1 1]); edgeFIS = addvar(edgeFIS,'input','Iy ',[-1 1]); sx = 0.1; sy = 0.1; edgeFIS = addmf(edgeFIS,'input',1,'zero','gaussmf',[sx 0]); edgeFIS = addmf(edgeFIS,'input',2,'zero','gaussmf',[sy 0]); edgeFIS = addvar(edgeFIS,'output','Iout',[0 1]);
wa = 0.1; wb = 1; wc = 1; ba = 0; bb = 0; bc = 0.7; edgeFIS = addmf(edgeFIS,'output',1,'white','trimf',[wa wb wc]); edgeFIS = addmf(edgeFIS,'output',1,'black','trimf',[ba bb bc]);
r1 = 'If Ix is zero and Iy is zero then Iout is white'; r2 = 'If Ix is not zero or Iy is not zero then Iout is black'; r = char(r1,r2); edgeFIS = parsrule(edgeFIS,r); showrule(edgeFIS)
I_fplt = zeros(size(I_gplt)); for ii = 1:size(I_gplt,1) I_fplt(ii,:) = evalfis([(Ix(ii,:));(Iy(ii,:));]',edgeFIS); end
figure('Name','Segmentation Using Fuzzy Logic','NumberTitle','Off'); imshow(I_fplt,[]); axis off; title('PLT Segmentation Using Fuzzy Logic','fontsize',12,'fontname','Times New Roman','color','Black'); %figure,imshow(~Seg_Im);title('Fuzzy');
I_adf=adaptivethreshold(I_fplt,11,0.1,0);
figure('Name','Segmentation Process','NumberTitle','Off'); imshow(I_adf); axis off; title('Adaptivethreshold','fontsize',12,'fontname','Times New Roman','color','Black');
%% Proposed Segmentation Method %%
% Fuzzy + Sobel % I_sobelf = double(I_adf);
for i=1:size(I_sobelf,1)-2 for j=1:size(I_sobelf,2)-2 %Sobel mask for x-direction: mx=((2*I_sobelf(i+2,j+1)+I_sobelf(i+2,j)+I_sobelf(i+2,j+2))-(2*I_sobelf(i,j+1)+I_sobelf(i,j)+I_sobelf(i,j+2))); %Sobel mask for y-direction:m my=((2*I_sobelf(i+1,j+2)+I_sobelf(i,j+2)+I_sobelf(i+2,j+2))-(2*I_sobelf(i+1,j)+I_sobelf(i,j)+I_sobelf(i+2,j)));
I_adf(i,j)=sqrt(mx.^2+my.^2); end end % subplot(2,2,2) figure,imshow(I_adf); title('fuzzy Sobel gradient'); %pause(2) %Define a threshold value
%Thresh=50; %I_fplt=max(I_fplt,Thresh); %I_fplt(I_fplt==round(Thresh))=0; %I_fplt=uint8(I_fplt);
%subplot(2,2,3) %figure,imshow(~I_fplt);title('fuzzy Sobel edge detection');
% Fuzzy + Prewitt %
I_prf = edge(I_adf,'prewitt'); figure,imshow(I_prf);title('Fuzzy Prewitt Edge detected Image');
% Fuzzy + Canny %
I_cf = edge(I_adf,'Canny');
figure('Name','Segmentation Process','NumberTitle','Off'); imshow(I_cf); axis off; title('Fuzzy Canny Edge Detector','fontsize',12,'fontname','Times New Roman','color','Black');
%% Feature Extraction %
% LoG Lindeberg Algorithm %
LoG_Pt = LoG_Lindeberg(I_adf); draw(~I_adf,LoG_Pt,'LoG Lindeberg');
% Harris Laplace Algorithm % HarrisLaplace_Pt = Harris_Laplace(I_adf); draw(~I_adf,HarrisLaplace_Pt,'Harris Laplace');
% Harris Algorithm % Harris_Pt = Harris(I_adf); draw(~I_adf,Harris_Pt,'Harris');
%% % Features Value %%%
Feat_LoG = [mean(LoG_Pt(1)) mean(LoG_Pt(2)) mean(LoG_Pt(3))]; Feat_HarrisLaplace = [mean(HarrisLaplace_Pt(1)) mean(HarrisLaplace_Pt(2)) mean(HarrisLaplace_Pt(3))]; Feat_Harris = [mean(Harris_Pt(1)) mean(Harris_Pt(2)) mean(Harris_Pt(3))]; Test_Features = [Feat_LoG Feat_HarrisLaplace Feat_Harris]; save Test_Features Test_Features
f=figure('Name','Test Features Values','NumberTitle','off'); t = uitable('Parent',f,'Data',Test_Features');
%% Classification %%
load Train_Features load Test_Features load Label load Filename
f=figure('Name','Train Features Values','NumberTitle','off'); t = uitable('Parent',f,'Data',Train_Features);
% PNN Classifier %
load Label T = ind2vec(Label); net = newpnn(Train_Features',T); Y = net(Test_Features'); Class = vec2ind(Y);
if Class==1 msgbox('Epidural Hematoma'); elseif Class==2 msgbox('Subarachnoid Hematoma'); else msgbox('Subdural Hematoma'); end %% Performance Measure %%
Actual = Label; POS = 3; Predicted = Label; Predicted (POS) =3;
Result = Evaluate(Actual,Predicted);
figure('Name','Performance Measures','NumberTitle','Off','Color','White'); bar(1,Result(1),0.5,'m') ; hold on ; bar(2,Result(2),0.5,'c') ; hold on ; bar(3,Result(3),0.5,'g') ; set(gca, 'XTick',1:7, 'XTickLabel',{'Accuracy' 'Sensitivity' 'Specificity' },'fontsize',12,'fontname','Times New Roman','fontweight','bold');

Réponses (0)

Catégories

En savoir plus sur Fuzzy Logic Toolbox dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by