?? eigenfacecreatedemo.m
字號(hào):
% A small demo to create eigenface picturesfunction EigenfaceCreateDemo% training datafor i=1:5 It(:,:,i) = imread(sprintf('image/face%02d.gif', i));end[nRow, nCol, N] = size(It);Xt = reshape(double(It), [], 5);Ct = [1 2 3 4 5];% PCA[U, Me] = cvPca(Xt);[D, M] = size(U);% imshow meanfaceY = reshape(uint8(Me), nRow, nCol);figure(M+1); imshow(Y);imwrite(Y, sprintf('result/meanface.png'), 'PNG');% imshow eigenfacesfor i=1:M Y = reshape(U(:,i), nRow, nCol); Y = uint8(cvuNormalize(Y, [0, 255])); % normalize to plot figure(i); imshow(Y); imwrite(Y, sprintf('result/eigenface%02d.png', i), 'PNG');end% composed by component j[Y, TX, Ratio] = cvPcaProj(Xt, U, Me);[M N] = size(Ratio);for i = 1:N, fprintf('face%02d: \r', i); for j = 1:M, fprintf('%02d%% is composed by eigenface%d. \r', ... round(Ratio(j,i)*100), j); endend
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -