for i=2:length(abc(:,1,1))
for j=2:length(abc(1,:,1))
if abc(i,j,1)>220&&abc(i,j,2)>220&&abc(i,j,3)>220 %将地板变为黑色
abc(i,j,:)=0;
end
if abc(i,j,1)&&abc(i,j,2)&&abc(i,j,3) %将非黑的变为黑的,黑的变为白的
abc(i,j,:)=0;
else
abc(i,j,:)=255;
end
end
end
%取每个园斑的特征点
cout=0;
r=double(abc);
for i=1:6:length(abc(:,1,1))
for j=1:6:length(abc(1,:,1))
if r(i,j,1)==0
%&&r(i+5,j,1)==0&&r(i,j+5,1)==0
cout=cout+1;
x(cout,:)=[i,j];
end
end
end
figure(1)
plot(x(:,1),x(:,2),'.')
%利用最短距离法求个个园斑的中心点
y=pdist(x);
z=linkage(y);
t= cluster(z,36);
for i=1:36
a=[0,0]; count=0;
for j=1:length(t)
if t(j)==i
count=count+1;
a=a+x(j,:);
end
end
b(i,:)=a/count;
end
%提取圆斑内的色素:
plot(b(:,1),b(:,2),'or')
abc=imread(mm);
data(36,3)=0;
data1=0;
data2=0;
data3=0;
cout=0;
b=fix(b);
for i=1:36
for j=(b(i,1)-2):(b(i,1)+2)
for k=(b(i,2)-2):(b(i,2)+2)
cout=cout+1;
data1=data1+double(abc(j,k,1));
data2=data2+double(abc(j,k,2));
data3=data3+double(abc(j,k,3));
end
end
data(i,1)=data1/cout;
data(i,2)=data2/cout;
data(i,3)=data3/cout;
end
%兰氏距离法:
%欧氏距离求时间:
t=zeros(1,33);
for i=1:33
if ou(i)==1
t1=[0,1,5,30,60,90,120,180,240];
for j=1:9;
www.youerw.com
[c,d]=min(ds);
if d>=b
d=d+1;
end
t(i)=t1(b)*a/(a+c)+t1(d)*c/(a+c);
clear ds
end
if ou(i)==2
t2=[0,5,30,60,180,240];
for j=1:6;
dc2(i,j)=(wholemydata(:,i)-jc2(:,j))'*(wholemydata(:,i)-jc2(:,j));
end
[a,b]=min(dc2(i,:));
ds=dc2(i,[1:b-1,b+1:6]);
[c,d]=min(ds);
if d>=b
d=d+1;
end
t(i)=t2(b)*a/(a+c)+t2(d)*c/(a+c);
clear ds
end
if ou(i)==3
t3=[0,5,30,60,90,120,180,240];
for j=1:8;