ORL人脸数据集

The Database of Faces

Our Database of Faces, (formerly ‘The ORL Database of Faces’), contains a set of face images taken between April 1992 and April 1994 at the lab. The database was used in the context of a face recognition project carried out in collaboration with the Speech, Vision and Robotics Group of the Cambridge University Engineering Department.

There are ten different images of each of 40 distinct subjects. For some subjects, the images were taken at different times, varying the lighting, facial expressions (open / closed eyes, smiling / not smiling) and facial details (glasses / no glasses). All the images were taken against a dark homogeneous background with the subjects in an upright, frontal position (with tolerance for some side movement). A preview image of the Database of Faces is available.

The files are in PGM format, and can conveniently be viewed on UNIX (TM) systems using the ‘xv’ program. The size of each image is 92x112 pixels, with 256 grey levels per pixel. The images are organised in 40 directories (one for each subject), which have names of the form sX, where X indicates the subject number (between 1 and 40). In each of these directories, there are ten different images of that subject, which have names of the form Y.pgm, where Y is the image number for that subject (between 1 and 10).

The database can be retrieved from http://www.cl.cam.ac.uk/Research/DTG/attarchive:pub/data/att_faces.tar.Z as a 4.5Mbyte compressed tar file or fromhttp://www.cl.cam.ac.uk/Research/DTG/attarchive:pub/data/att_faces.zip as a ZIP file of similar size.

A convenient reference to the work using the database is the paper Parameterisation of a stochastic model for human face identification. Researchers in this field may also be interested in the author’s PhD thesis, Face Recognition Using Hidden Markov Models, available fromhttp://www.cl.cam.ac.uk/Research/DTG/attarchive/pub/data/fsamaria_thesis.ps.Z (~1.7 MB).

When using these images, please give credit to AT&T Laboratories Cambridge.

UNIX is a trademark of UNIX System Laboratories, Inc.

Contact information

Copyright © 2002 AT&T Laboratories Cambridge

以下是利用KL变换实现人脸判断的MATLAB代码,其中使用了ORL人脸数据集: ```matlab %% 读取ORL人脸数据集 clear all; close all; clc; % 数据集路径 data_path = './orl_faces'; % 读取数据 for i=1:40 for j=1:10 file_name = strcat(data_path, '/', 's', num2str(i), '/', num2str(j), '.pgm'); img = imread(file_name); img = double(img(:)'); orl_data(i,j,:) = (img - mean(img))/std(img); % 标准化处理 end end %% KL变换 % 计算平均脸 mean_face = mean(orl_data,2); mean_face = reshape(mean_face, 40, []); % 计算协方差矩阵 X = reshape(orl_data, [], 10); X = X'; C = cov(X); % 计算特征值和特征向量 [V,D] = eig(C); % 特征向量按照特征值大小排序 [d,ind] = sort(diag(D),'descend'); Ds = D(ind,ind); Vs = V(:,ind); % 选择前k个主成分 k = 20; Vs = Vs(:,1:k); Ds = Ds(1:k,1:k); % 计算投影矩阵 P = Vs'; % 计算投影系数 proj_coef = P*(orl_data - repmat(mean_face, [1, 10])); %% 训练 % 每个人的前N张图像作为训练集,剩下的作为测试集 N = 8; train_data = proj_coef(:,1:N:end); test_data = proj_coef; test_data(:,1:N:end) = []; % 计算训练集中每个人的平均脸 train_mean_face = mean(train_data,2); % 计算每个人的投影系数的均值向量 train_mean_proj = zeros(20,40); for i=1:40 train_mean_proj(:,i) = mean(train_data(:,i:N:i+N-1),2); end % 计算类内散度矩阵Sw和类间散度矩阵Sb Sw = zeros(20,20); Sb = zeros(20,20); for i=1:40 Sw = Sw + cov(train_data(:,i:N:i+N-1)'); tmp = train_mean_proj(:,i) - train_mean_face; Sb = Sb + N*tmp*tmp'; end % 计算广义特征值和广义特征向量 [Vg,Dg] = eig(Sb,Sw); [d,ind] = sort(diag(Dg),'descend'); Vgs = Vg(:,ind); % 选择前K个主成分 K = 19; Vgs = Vgs(:,1:K); % 计算投影矩阵 W = P*Vgs; % 计算训练集和测试集的投影系数 train_proj = W'*train_data; test_proj = W'*test_data; % 判别阈值 threshold = 1.7; %% 测试 correct = 0; for i=1:size(test_proj,2) min_dist = Inf; for j=1:40 dist = norm(train_proj(:,j) - test_proj(:,i)); if dist < min_dist min_dist = dist; min_index = j; end end if min_dist < threshold fprintf('The %dth test image is recognized as the %dth person.\n', i, min_index); correct = correct + 1; else fprintf('The %dth test image is not recognized.\n', i); end end % 计算识别率 accuracy = correct / size(test_proj,2); fprintf('The accuracy is %.2f%%.\n', accuracy*100); ``` 注:代码中的KL变换指的是离散KL变换,也称为PCA。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值