📄 example75_eigenvalue.m
字号:
%%%example75_eigenvalue
b0(:,1)=reshape(double(rgb2gray(img1)),32*32,1);
b0(:,2)=reshape(double(rgb2gray(img2)),32*32,1);
%caculate the eigenvalues and the eigenvectors of the cov matrix
b=(b0(:,1)+b0(:,2))/2;
B1=b0';
C=cov(B1,1);
[V,D]=eig(C);
W0=V;
[m,n]=size(b0);
for j=1:m-1
for i=1:m-j
if D(i,i)<D(i+1,i+1)
temp1=D(i,i);
D(i,i)=D(i+1,i+1);
D(i+1,i+1)=temp1;
temp2=W0(:,i);
W0(:,i)=W0(:,i+1);
W0(:,i+1)=temp2;
end
end
end
cpts=16;
i=1:cpts;
W(:,i)=W0(:,i);
T=ones(16,1);
for x=1:16
T(x)=D(x,x);
end
figure('name','前16个特征值','numbertitle','off');
x=1:16;
plot(x,T(x));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -