clc;clear;
offsets = [0 1;-1 1;-1 0;-1 -1]; %????????
mean_texture=[];
var_texture=[];
for i=0:6:24
for j=4:4:12
for k=1:3
if exist(strcat('N',num2str(i),'K',num2str(j),'_',num2str(k),'.tif')) %????????
strcat('N',num2str(i),'K',num2str(j),'_',num2str(k),'.tif') %?????
I=imread(strcat('N',num2str(i),'K',num2str(j),'_',num2str(k),'.tif')); %???
%ndvi=(I(:,:,6)-I(:,:,3))./(I(:,:,6)+I(:,:,3)); %ndvi=(I(:,:,9)-I(:,:,5))./(I(:,:,9)+I(:,:,5));
vari=(I(:,:,3)-I(:,:,5))./(I(:,:,3)+I(:,:,5)-I(:,:,1)); %vari=(I(:,:,2)-I(:,:,3))./(I(:,:,2)+I(:,:,3)-I(:,:,1));
%savi=1.5*(I(:,:,6)-I(:,:,3))./(I(:,:,6)+I(:,:,3)+0.5);%savi=1.5*(I(:,:,9)-I(:,:,5))./(I(:,:,9)+I(:,:,5)+0.5);
%ari=(1./I(:,:,3))-(1./I(:,:,7)); %ari=(1./I(:,:,2))-(1./I(:,:,5));
%rvi1=I(:,:,9)./I(:,:,6); %rvi1=I(:,:,6)./I(:,:,4);
%rvi2=I(:,:,6)./I(:,:,2); %rvi2=I(:,:,9)./I(:,:,3);
%cired=I(:,:,9)./I(:,:,8)-1;%cired=I(:,:,6)./I(:,:,5)-1;
[nrow,ncol]=size(vari); %??????
N=0;
contrast=zeros(1,4);
correlation=zeros(1,4);
energy=zeros(1,4);
homogeneity=zeros(1,4);
%7*7???????????
for n=6:nrow-6
for m=6:ncol-6
mint=min(min(vari));
maxt=max(max(vari));
GLCM=graycomatrix(vari,'GrayLimits',[mint,maxt],'NumLevels',16,'offset',offsets); %????????
%GLCM=graycomatrix(savi,'offset',offsets);
%GLCM=graycomatrix(ari,'offset',offsets);
%GLCM=graycomatrix(rvi1,'offset',offsets);
%GLCM=graycomatrix(rvi2,'offset',offsets);
%GLCM=graycomatrix(cired,'offset',offsets);
%??????????????
stats=graycoprops(GLCM);
%mean_texture(i*3/4+j,1)=mean(mean(cired)); %change
contrast=contrast+stats.Contrast;
correlation=correlation+stats.Correlation;
energy=energy+stats.Energy;
homogeneity=homogeneity+stats.Homogeneity;
N=N+1;
end
end
%?????????????
mean_texture(i*3/4+j*3/4+k,2)=mean(contrast/N);
mean_texture(i*3/4+j*3/4+k,3)=mean(correlation/N);
mean_texture(i*3/4+j*3/4+k,4)=mean(energy/N);
mean_texture(i*3/4+j*3/4+k,5)=mean(homogeneity/N);
else
mean_texture(i*3/4+j*3/4+k,1)=0;
mean_texture(i*3/4+j*3/4+k,2)=0;
mean_texture(i*3/4+j*3/4+k,3)=0;
mean_texture(i*3/4+j*3/4+k,4)=0;
mean_texture(i*3/4+j*3/4+k,5)=0;
end
end
end
end