【人脸识别】基于直方图Histogram实现人脸识别附matlab代码

本文探讨了Eigenfaces人脸识别算法在光照敏感性问题上的改进,通过光照锥方法对图像进行补偿,并结合Matlab代码展示了如何使用FR_Processed_histogram函数处理图像。研究还介绍了如何使用Fisherfaces和LBPHfaces算法作为对比。

 1 内容介绍

人脸识别算法主要包括Eigenfaces算法、Fisherfaces算法与LBPHfaces算法。Eigenfaces算法将高维的人脸图像降维映射到低维特征脸子空间,实现面部特征采集,该算法特征数据多、识别准确率高。Fisherfaces算法在低维空间达到最大类间离散度与最小类内离散度,对不同的数据集计算其相应的特征。LBPHfaces算法采用局部特征值的描述方法,通过提取图像局部细节描述其纹理特征。

本文设计选用Eigenfaces算法。该算法虽然具有较高的识别率,但对光照因素较为敏感,因此光照因素的存在导致系统具有较高的误识率与拒识率。本文采用光照锥方法对图像进行光照补偿。

光照锥即不同光源方向的图像叠加形成的凸型锥体。光照锥方法基于光度立体视觉方法,使用前提是样本为理想散射模型,即可在固定光照下的所有视场方向观测到物体表面。算法思想是在构建特征脸时利用光照锥生成新的图像样本。

首先,加载用于训练的图像样本,将图像样本转换成矩阵向量形式与表示光源方向矩阵。其次,根据单一光源人脸表面的阴影计算出光源的反射率与表面法向量,由这些信息可以得到三维人脸重构图像与光源方向的估计值。最后,通过改变光源的方向,计算出不同光源下的合成图像。通过丰富特征脸的图像光源信息,实现在构建特征脸阶段减少光照对人脸识别系统的干扰。

2 仿真代码

function varargout = FR_Processed_histogram(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @FR_Processed_histogram_OpeningFcn, ...
    'gui_OutputFcn',  @FR_Processed_histogram_OutputFcn, ...
    'gui_LayoutFcn',  [] , ...
    'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end

function FR_Processed_histogram_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
global total_sub train_img sub_img max_hist_level bin_num form_bin_num;
total_sub = 40;

        sum = sum + abs( test_processed_bin(z) - train_processed_bin(z,y) );
    end
    img_bin_hist_sum(K,1) = sum;
    sum = 0;
    K = K + 1;
end
[temp M] = min(img_bin_hist_sum);
M = ceil(M/5);
getString_start=strfind(pathname,'S');
getString_start=getString_start(end)+1;
getString_end=strfind(pathname,'\');
getString_end=getString_end(end)-1;
subjectindex=str2num(pathname(getString_start:getString_end));
if (subjectindex == M)
    axes (handles.axes3)
    %image no: 5 is shown for visualization purpose
    imshow(imread(strcat('ORL\S',num2str(M),'\5.bmp')))
    msgbox ( 'Correctly Recognized');
else
    display ([ 'Error==>  Testing Image of Subject >>' num2str(subjectindex) '  matches with the image of subject >> '  num2str(M)])
    axes (handles.axes3)
    %image no: 5 is shown for visualization purpose
    imshow(imread(STRCAT('ORL\S',num2str(M),'\5.bmp')))
    msgbox ( 'Incorrectly Recognized');
end
display('Testing Done')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function box_Callback(hObject, eventdata, handles)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function box_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
%% 响应Input Image按钮
function Input_Image_button_Callback(hObject, eventdata, handles)
global filename pathname I
[filename, pathname] = uigetfile('*.bmp', 'Test Image');
axes(handles.axes1)
imgpath=strcat(pathname,filename);
I = imread(imgpath);
imshow(I)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function axes3_CreateFcn(hObject, eventdata, handles)
 

3 运行结果

4 参考文献

[1]聂倩倩, 秦润泽, 高育新,等. 基于直方图均衡化的人脸识别系统设计与实现[J]. 物联网技术, 2018, 8(7):3.

[2]杨恢先, 唐金鑫, 陶霞,等. 基于韦伯梯度方向直方图的人脸识别算法[J]. 计算机工程与应用, 2017, 53(15):6.

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

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

基于Matlab直方图Histogram人脸识别程序-Processed histogram based Face Recognition.part3.rar 基于Matlab 直方图Histogram人脸识别程序 因为数据库图片太大,所以分成几个压缩文件。 Face recognition 原理介绍: matlab12.jpg Recognizing objects from large image databases, histogram based methods have proved simplicity and usefulness in last decade. Initially, this idea was based on color histograms that were launched by swain [1]. This algorithm presents the first part of our proposed technique named as “Histogram processed Face Recognition” [2] For training, grayscale images with 256 gray levels are used. Firstly, frequency of every gray-level is computed and stored in vectors for further processing. Secondly, mean of consecutive nine frequencies from the stored vectors is calculated and are stored in another vectors for later use in testing phase. This mean vector is used for calculating the absolute differences among the mean of trained images and the test image. Finally the minimum difference found identifies the matched class with test image. Recognition accuracy is of 99.75% [1] M. J. Swain and D. H. Ballard, “Indexing via color histogram”, In Proceedings of third international conference on Computer Vision , pages 390–393, Osaka, Japan, 1990. [2] Fazl-e-Basit, Younus Javed and Usman Qayyum, "Face Recognition using processed histogram and phase only correlation ", 3rd IEEE International Conference on Emerging Technology pp. 238-242
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值