cbcldata.m
来自「NMFs算法(带稀疏度约束的非负稀疏矩阵分解)用于实现基于人脸局部特征的人脸识别」· M 代码 · 共 45 行
M
45 行
function V = cbcldata% cbcldata - read face image data from cbcl database%global imloadfunc; % This is where the cbcl face images residethepath = '../data/cbcl-face-database/face/';% Create the data matrixV = zeros(19*19,2429);% Read the directory listingD = dir(thepath);% Step through each image, reading it into the data matrix% Note: The (+2) is just to avoid '.' and '..' entriesfprintf('Reading in the images...\n');for i=1:2429, switch imloadfunc, case 'pgma_read', I = pgma_read([thepath D(i+2).name]); otherwise, I = imread([thepath D(i+2).name]); end V(:,i) = reshape(I,[19*19, 1]); if rem(i,100)==1, fprintf('[%d/24]',floor(i/100)); endendfprintf('\n');% Same preprocessing as Lee and SeungV = V - mean(V(:));V = V / sqrt(mean(V(:).^2));V = V + 0.25;V = V * 0.25;V = min(V,1);V = max(V,0);% Additionally, this is required to avoid having any exact zeros:% (divergence objective cannot handle them!)V = max(V,1e-4);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?