主程序:
..........
[m,n,p]=size(rgb);
l_color=lab(:,:,1);
a_color=lab(:,:,2);
b_color=lab(:,:,3);
array=1;
l_color2=zeros(1,m*n);
a_color2=zeros(1,m*n);
b_color2=zeros(1,m*n);
for j=1
for i=1
l_color2(array)=lab(i,j,1);
a_color2(array)=lab(i,j,2);
b_color2(array)=lab(i,j,3);
i=i+1;
array=array+1;
end
j=j+1;
end
Distance(l_color2,a_color2,b_color2,m*n);
调用的子程序Distance
function value=Distance(l_color,a_color,b_color,n)
Distance=zeros(n,n);
for i=1:n
for j=1:n
if i~=j
Distance(i,j)=sqrt((l_color(i)-l_color(j))^2+(a_color(i)-a_color(j))^2+(b_color(i)-b_color(j))^2);
else
Distance(i,j)=1000;
end
j=j+1;
end
i=i+1;
end
呼啦一阵风
吃鸡游戏