HI, I have the below code to perform a DWT and then perform feature extractions. However, I'm having difficulty saving the extraction values into .xlsx format because every new entry gets overwritten, and the 1st column values and 2nd column 1st row values are wrong (scroll down to the last part for the xlsx result). Please advise how I can go about doing this as I'm very new to MATLAB. Thank you.
srcFile = dir('filepath');
for i = 1:length(srcFile)
filename = strcat('filepath',srcFile(i).name);
j = imread(filename);
[xar,xhr,xvr,xdr] = dwt2(j(:,:,1),'bior5.5');
[xag,xhg,xvg,xdg] = dwt2(j(:,:,1),'bior5.5');
[xab,xhb,xvb,xdb] = dwt2(j(:,:,1),'bior5.5');
xa(:,:,1) = xar ; xa(:,:,2) = xag ; xa(:,:,3) = xab;
xh(:,:,1) = xhr ; xh(:,:,2) = xhg ; xh(:,:,3) = xhb;
xv(:,:,1) = xvr ; xv(:,:,2) = xvg ; xv(:,:,3) = xvb;
xd(:,:,1) = xdr ; xd(:,:,2) = xdg ; xd(:,:,3) = xdb;
[xaar,xhhr,xvvr,xddr] = dwt2(xa(:,:,1),'bior5.5');
[xaag,xhhg,xvvg,xddg] = dwt2(xa(:,:,1),'bior5.5');
[xaab,xhhb,xvvb,xddb] = dwt2(xa(:,:,1),'bior5.5');
xaa(:,:,1) = xaar ; xaa(:,:,2) = xaag ; xaa(:,:,3) = xaab;
xhh(:,:,1) = xhhr ; xhh(:,:,2) = xhhg ; xhh(:,:,3) = xhhb;
xvv(:,:,1) = xvvr ; xvv(:,:,2) = xvvg ; xvv(:,:,3) = xvvb;
xdd(:,:,1) = xddr ; xdd(:,:,2) = xddg ; xdd(:,:,3) = xddb;
DWT_feat = [xaa,xhh,xvv,xdd];
gray = rgb2gray(DWT_feat);
glcm = graycomatrix(gray);
stats = graycoprops(glcm,'Contrast Correlation Energy Homogeneity');
Contrast = stats.Contrast;
Correlation = stats.Correlation;
Energy = stats.Energy;
Homogeneity = stats.Homogeneity;
Mean = mean2(DWT_feat);
StdDev = std2(DWT_feat);
Entropy = entropy(DWT_feat);
RMS = mean2(rms(DWT_feat));
Variance = mean2(var(double(DWT_feat)));
a = sum(double(DWT_feat(:)));
Smoothness = 1-(1/(1+a));
Kurtosis = kurtosis(double(DWT_feat(:)));
Skewness = skewness(double(DWT_feat(:)));
VariableNames = {'Contrast','Correlation', 'Energy', 'Homogeneity', 'Mean', 'StdDev', 'Entropy', 'RMS', 'Variance', 'Smoothness', 'Kurtosis', 'Skewness'};
T = table(Contrast(:), Correlation(:), Energy(:), Homogeneity(:), Mean(:), StdDev(:), Entropy(:), RMS(:), Variance(:), Smoothness(:), Kurtosis(:), Skewness(:));
AT = array2table(T,'VariableNames', {'Contrast','Correlation', 'Energy', 'Homogeneity', 'Mean', 'StdDev', 'Entropy', 'RMS', 'Variance', 'Smoothness', 'Kurtosis', 'Skewness'});
disp(AT);
xlswrite('savepath',AT,'Sheet1','A1');
end
Result (which is wrong):
A T Energy Homogeneity Mean StdDev Entropy RMS Variance Smoothness Kurtosis Skewness
T 0.720361 0.3986 0.871775 24.72161 95.91721 1.395854 37.76407 4277.009 1 32.69805 5.19293