当前位置 : 主页 > 编程语言 > python >

【图像检测】基于K-L实现人脸检测附matlab代码

来源:互联网 收集:自由互联 发布时间:2022-09-29
1 内容介绍 人脸识别作为一种重要的个人身份鉴别方法,可广泛地应用于证件核对、公安追逃、信用卡验证、自动取款机(ATM)等方面..与利用指纹、手掌、视网膜、虹膜等其他人体生物特

1 内容介绍

人脸识别作为一种重要的个人身份鉴别方法,可广泛地应用于证件核对、公安追逃、信用卡验证、自动取款机(ATM)等方面..与利用指纹、手掌、视网膜、虹膜等其他人体生物特征进行人身鉴别的方法相比,人脸识别具有直接、友好、方便的特点.一个完整的人脸识别系统包括人脸检测、特征提取、以及匹配识别.人脸检测是其中的第一步,也是人脸识别系统的重要步骤.本文研究了对在几种不同的光照补偿方法处理后的图像上使用K-L算法及奇异值分解实现的人脸自动检测方法,提出了一种工程方法,该方法自动的选择适应指定"检测精度"的特征脸的个数,排除特征脸空间中能量值较小的特征轴,降低了选择特征脸空间中的能量集中的轴的工作难度.首先基于K-L展开式的特征提取,以输入样本中每个人的平均样本和所有人的平均样本组成类间离散矩阵,作为K-L变换的产生矩阵,对该矩阵进行奇异值分解,获得特征脸空间,同时得到训练样本在该空间得一组投影系数,即代数特征.其次,将待测图像向该空间投影,得到待测图像得代数特征.接着,对比待测图像和训练样本的代数特征,在对比过程中,根据指定的精度,选取对应适当的特征脸个数的训练样本的代数特征个数,与待测图像的代数特征求欧式距离,根据该距离检测待测图像是否是人脸.从实验结果可以看出,本文提出的方法具有一定的鲁棒性,可以适应样本训练个数变化较大的环境,同时可以有效的排除特征脸空间中能量值较小的特征轴,在训练样本比较多的情况下,可以有效的减少选择特征脸空间中能量值集中的轴的工作量.得到尽可能少且最有人脸代表性的特征脸子空间. 

2 部分代码

% Version : 4.1

% Author  : Omid Bonakdar Sakhi


function IMVECTOR = im2vec (W27x18)


%{

The input of the function is a 27x18 window . At first the function adjusts

the histogram of the window . Then to convolve the window with Gabor 

filters , the window in frequency domain will multiply by gabor filters


Gabor filters are stored in gabor.mat . to save time they have been saved 

in frequency domain before.

%} 


load gabor; %loading Gabor filters


% Adjust the window histogram , the parameters are set with try and error

W27x18 = adapthisteq(W27x18,'Numtiles',[8 3]); 


Features135x144 = cell(5,8);

for s = 1:5

    for j = 1:8

        Features135x144{s,j} = ifft2(G{s,j}.*fft2(double(W27x18),32,32),27,18);

    end

end


% Features135x144 is a cell array contains the result of the convolution of

% the window with each of the fourty gabor filters. These matrixes will

% concate to form a big 135x144 matrix of complex numbers/

% We only need the magnitude of the result That is why the abs is used.

Features135x144 = abs(cell2mat(Features135x144));


% 135x144 is very painful to be an input for the network . it has 19,400

% pixels . It means that the input vector of the network should have 19,400

% pixels which means a large amount of computation and waste of time.

% so We reduce the matrix size to one-third of it's original size.

% There are so many ways to reduce the matrix size like using PCA , using

% the median of each 3x3 pixels or deleting the rows and colums

% Deleting is not the best way , but it save more time compare with

% others

Features135x144 (3:3:end,:)=[];

Features135x144 (2:2:end,:)=[];

Features135x144 (:,3:3:end)=[];

Features135x144 (:,2:2:end)=[];


% The numbers in the input vector of the network should be between -1,1

% and the line below will fulfill this concept.

Features45x48 = premnmx(Features135x144);


% Change the matrix to a vector 

IMVECTOR = reshape (Features45x48,[2160 1]);


%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

% notes : This function is very critical . consider that we have a big

% photo say 400x300 . Can you say how may 27x18 windows we have ? 

% If we do not preprocess the photo to predict the location of the faces

% we have a window for each and every single pixel of the photo which means

% 120,000 windows ( A little less because of the borders ) . and each pixel

% is the center of a new window.

% if this function takes .4 sec to be executed , the whole photo will take

% about 13 hours only for the network preprocess .

% so any unnecessary line in this function can be a hell for the whole 

% process and we should optimize this function as possible as we can.

3 运行结果

【图像检测】基于K-L实现人脸检测附matlab代码_人脸检测

4 参考文献

[1]龙琰. 基于K-L变换的人脸检测[D]. 四川大学, 2004.

博主简介:擅长​​智能优化算法​​、​​神经网络预测​​、​​信号处理​​、​​元胞自动机​​、​​图像处理​​、​​路径规划​​、​​无人机​​、​​雷达通信​​、​​无线传感器​​等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。


【本文转自:美国cn2站群服务器 http://www.558idc.com/mggfzq.htm提供,感谢支持】
网友评论