资源简介
基于PCA的人脸识别定位,包含测试数据,真实可用
代码片段和文件信息
clc;
clear;
data = load(‘/Users/apple/Downloads/test.mat‘);
faces = data.FACES;
scale = 208/(max(max(faces)) - min(min(faces))); % normalize the image
faces = scale*(faces - min(min(faces)));
test = data.test;
figure;
imshow(test[]);
[rowscols] = size(test);
faces = faces‘;
[coeffscorelatenttsquare] = princomp(faces);
k = 1;
vector = zeros(121*1211600);
for i = 21 : rows - 19
for j = 21 : cols - 19
face_temp = test(i-20:i+19j-20:j+19);
vector(k:) = reshape(face_temp11600);
k = k + 1;
end
end
F = mean(faces);
P = coeff(:1:9);
x_tilde = zeros(146411600);
for i = 1 : 1600
for j = 1 : 14641
x_tilde(ji) = vector(ji) - F(1i);
end
end
score = x_tilde * P;
distance = ones(146411);
lambda = (1/6) * (sum(latent(1:61)));
rho = (1/3) * (sum(latent(7:91)));
for i = 1 : 14641
distance(i1) = sum(score(i1:6).^2)/lambda ...
+ (sum(x_tilde(i:).^2) - sum(score(i1:6).^2))/rho;
end
b = reshape(distance121121);
figure;
imshow(b[]);
title(‘distance‘ ‘FontSize‘ 15);
Pos = zeros(39);
% show the location of the faces identified
figure;
for i = 1:9
[rowcolval] = findPos(b);
Pos(1i) = row;
Pos(2i) = col;
Pos(3i) = val;
b = cleanNear(browcol);
subplot(33i);
imshow(b[]);
hold on;
plot(Pos(2i)Pos(1i)‘rs‘‘MarkerSize‘2);
end
figure;
imshow(test[]);
for i = 1 : 9
hold on;
plot(Pos(2i)+20Pos(1i)+20‘rs‘‘MarkerSize‘2);
end
% calculate the weight of the identified faces.
a = zeros(99);
k = 1;
for i = 1 : 9
row = Pos(1i);
col = Pos(2i);
subimage = test(row-20:row+19col-20:col+19);
subvector = reshape(subimage11600) - F;
a(k:) = subvector * coeff(:1:9);
k = k + 1;
end
% calculate the weight of the original training image.
g = zeros(99);
g(1:) = (faces(7:) - F) * coeff(:1:9);
g(2:) = (faces(4:) - F) * coeff(:1:9);
g(3:) = (faces(9:) - F) * coeff(:1:9);
g(4:) = (faces(8:) - F) * coeff(:1:9);
g(5:) = (faces(2:) - F) * coeff(:1:9);
g(6:) = (faces(6:) - F) * coeff(:1:9);
g(7:) = (faces(5:) - F) * coeff(:1:9);
g(8:) = (faces(1:) - F) * coeff(:1:9);
g(9:) = (faces(3:) - F) * coeff(:1:9);
% calculate the norm of the dfference between weights ai for each
% of the identified faces and the corresponding weights for the
%original training faces.
l = zeros(91);
for i = 1:9
temp = a(i:) - g(i:);
s = sum(temp.^2);
l(i1) = s^0.5;
end
% plot the distance vs.training face number
plot_dis = zeros(19);
plot_dis(11) = Pos(38);
plot_dis(12) = Pos(35);
plot_dis(13) = Pos(39);
plot_dis(14) = Pos(32);
plot_dis(15) = Pos(37);
plot_dis(16) = Pos(36);
plot_dis(17) = Pos(31);
plot_dis(18) = Pos(34);
plot_dis(19) = Pos(33);
figure;
plot(plot_dis);
title(‘distance vs training face number‘ ‘FontSize‘ 15);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-04-08 14:24 PCA浜鸿劯璇嗗埆\
文件 2879 2017-04-08 14:23 PCA浜鸿劯璇嗗埆\face_localization.m
目录 0 2017-04-08 14:24 __MACOSX\
目录 0 2017-04-08 14:24 __MACOSX\PCA浜鸿劯璇嗗埆\
文件 120 2017-04-08 14:23 __MACOSX\PCA浜鸿劯璇嗗埆\._face_localization.m
文件 41588 2017-03-31 10:43 PCA浜鸿劯璇嗗埆\faces.mat
文件 577 2017-03-31 10:43 __MACOSX\PCA浜鸿劯璇嗗埆\._faces.mat
文件 48847 2017-03-31 10:43 PCA浜鸿劯璇嗗埆\test.mat
文件 576 2017-03-31 10:43 __MACOSX\PCA浜鸿劯璇嗗埆\._test.mat
- 上一篇:HSMM程序matlab
- 下一篇:物体在空间中的运动轨迹预测
相关资源
- Gabor特征提取MATLAB代码
- 快速双边滤波matlab代码
- 图像处理之生成BMP图片MATLAB代码.m
- Butterworth滤波器Matlab代码
- 基于matlab,gui的人脸识别(PCA)
- 宽带相控阵天线matlab代码
- HDB3AMIRZNRZ等编码的MATLAB代码
- 无人驾驶车辆换道优化matlab代码
- 高斯过程回归模型MATLAB代码
- 8x8点DCT变换matlab代码
- 图像预处理MATLAB代码
- blocklms块自适应滤波器matlab代码
- 三相短路电流计算
- hough 检测直线、圆形matlab代码
- 灰色预测模型通用matlab代码
- stft和逆stft变换的Matlab代码
- 不同模拟滤波器设计matlab代码
- 使用扩展卡尔曼滤波训练的神经网络
- 无人驾驶车辆模型预测控制配套matl
- 人脸识别系统 现成的matlab代码
- 一种实时坏点检测和修复算法的matl
- 无向图中最大团问题的matlab代码
- UKF无迹卡尔曼滤波算法matlab代码
- 2dpca的matlab源代码 rar
- 有限元平面应力及桁架机构matlab代码
- tikhonnov正则化matlab代码包括L曲线法求
- 杜芬振子庞加莱截面MATLAB代码
- 基于PCA及SVM的人脸识别
- 蚁群算法粗糙集matlab代码
- 均值滤波和中值滤波matlab代码
评论
共有 条评论