Page 166 - Algorithm Collections for Digital Signal Processing Applications using MATLAB
P. 166
4. Selected Applications 155
5.2 M – program for Texture Images Clustering
___________________________________________________________
patclasgv.m
for i=1:1:23
S=strcat(num2str(i),'.bmp');
temp1=rgb2gray(imread(S));
A{i}=temp1(1:1:40,1:1:48);
temp2=blkproc(A{i},[8 8],'var2(x)');
FEA{i}=reshape(temp2,1,size(temp2,1)*size(temp2,2));
end
FEAVECT=cell2mat(FEA');
P=kmeans(FEAVECT,4);
for i=1:1:4
figure
[x,y]=find(P==i);
for j=1:1:length(x)
subplot(1,length(x),j)
imshow(A{x(j)})
end
end
_________________________________________________________
var2.m
function [res]=var2(x)
res=var(reshape(x,1,64));