All All '/test - Images/ .JPG' '/test - Images/': % Features For Abnormal Region

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

clc;

clear all;
close all;
S=pwd;
T='\Test_Images\*.jpg';
K=strcat(S,'\Test_Images\');

path=strcat(S,T);
D=dir(path);
tot_files=numel(D);
f_ab=[];
f_nor=[];
for i=1:tot_files

filename=strcat(K,D(i).name);
I=imread(filename);
if size(I,3) == 3
I=rgb2gray(I);
end
% features for abnormal
region
disp('Crop the abnormal
region in the image');
pause;
img=imcrop(I);
mn=mean(mean(img(:)));
stdev=std2(img);
sk=skewness(double(img(:)));

kur=kurtosis(double(img(:)));
enr=sum(img(:));
ent=entropy(img);
glcm= graycomatrix(img,
'offset', [0 1]);
stats = graycoprops(glcm);
glcm_feat=[stats.Contrast,
stats.Correlation,stats.Energy,s
tats.Homogeneity];
f_ab=[f_ab; mn stdev sk kur
enr ent glcm_feat];
% features for normal region
disp('Crop the normal region
in the image ');
pause;
img=imcrop(I);
mn=mean(mean(img(:)));
stdev=std2(img);
sk=skewness(double(img(:)));

kur=kurtosis(double(img(:)));
enr=sum(img(:));
ent=entropy(img);
glcm= graycomatrix(img,
'offset', [0 1]);
stats = graycoprops(glcm);
glcm_feat=[stats.Contrast,
stats.Correlation,stats.Energy,s
tats.Homogeneity];
f_nor=[f_nor; mn stdev sk
kur enr ent glcm_feat];
end

You might also like