clc;
clear;
a=imread('12.png');
[m,n,o]=size(a);
I=zeros(m*n,3);
k = 1;
for i=1:m
for j=1:n
I(k,:)=a(i,j,:);
k = k+1;
end
end
B = unique(I,'rows');
fid=fopen('123.xls','wt');
[m1 n1] =size(B);
for i=1:1:m1
for j=1:1:n1
if j==n1 %如果一行的个数达到n个则换行,否则空格
fprintf(fid,'%d\n',B(i,j));
else
fprintf(fid,'%d\t',B(i,j));
end
end
end
fclose(fid);