prex_eigenfaces.m
来自「The pattern recognition matlab toolbox」· M 代码 · 共 47 行
M
47 行
%PREX_EIGENFACES PRTools example on the use of images and eigenfaceshelp prex_eigenfacesecho on % Load one image per each subject (may take a while) a = faces([1:40],1); % Compute the eigenfaces w = pca(a); % Display them newfig(1,3); show(w); drawnow; % Project all faces onto the eigenface space b = []; for j = 1:40 a = faces(j,[1:10]); b = [b;a*w]; % Don't echo loops echo off end echo on % Show a scatterplot of the first two eigenfaces newfig(2,3) scatterd(b) title('Scatterplot of the first two eigenfaces') % Compute leave-one-out error curve featsizes = [1 2 3 5 7 10 15 20 30 39]; e = zeros(1,length(featsizes)); for j = 1:length(featsizes) k = featsizes(j); e(j) = testk(b(:,1:k),1); echo off end echo on % Plot error curve newfig(3,3) plot(featsizes,e) xlabel('Number of eigenfaces') ylabel('Error')echo off
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?