人脸识别---人脸图像预处理
2015-11-11 11:03
656 查看
Abstrcat—人脸图像预处理是为了去除光照对人脸影响。
通常我们采用直方图均衡化对人脸图像进行处理。下面介绍一个方法对人脸进行预处理,由于没有找到相关文献的介绍,现在只能给出公式以及该方法与直方图均衡化后的结果。该方法最终得到识别率比直接采用直方图均衡化好。
对于一幅尺寸为m∗n 人脸图像I .
I 1 =I(∑ m i=1 ∑ n j=1 |I ij | a /(m∗n)) (1/a)
I 2 =I 1 (∑ m i=1 ∑ n j=1 min(trim,|I ij |) a /(m∗n)) (1/a)
I 3 =trim∗tanh(Itrim )
其中trim=10
下图是均衡化和本方法的处理结果图
最左边的图是原始光照不强的人脸图像,中间是均衡化后图像,右边通过本文方法提取的图像。可以看出右图处理已经有了一定的纹理特性,实验表明对后续人脸识别有帮助。
psTan.m
preproc2.m
gaussianfilter.m
gauss.m
fftcoord.m
调用方式:
src输入为灰度图像: dst = psTan(src);
通常我们采用直方图均衡化对人脸图像进行处理。下面介绍一个方法对人脸进行预处理,由于没有找到相关文献的介绍,现在只能给出公式以及该方法与直方图均衡化后的结果。该方法最终得到识别率比直接采用直方图均衡化好。
对于一幅尺寸为m∗n 人脸图像I .
I 1 =I(∑ m i=1 ∑ n j=1 |I ij | a /(m∗n)) (1/a)
I 2 =I 1 (∑ m i=1 ∑ n j=1 min(trim,|I ij |) a /(m∗n)) (1/a)
I 3 =trim∗tanh(Itrim )
其中trim=10
下图是均衡化和本方法的处理结果图
最左边的图是原始光照不强的人脸图像,中间是均衡化后图像,右边通过本文方法提取的图像。可以看出右图处理已经有了一定的纹理特性,实验表明对后续人脸识别有帮助。
psTan.m
function img = psTan(imgRaw) % parameter setting for preprocessing gamma = 0.2; % gamma parameter sigma0 = 1; % inner Gaussian size sigma1 = -2; % outer Gaussian size sx = 0; % x offset of centres of inner and outer filter sy = 0; % y offset of centres of inner and outer filter mask = []; % mask do_norm = 10; % Normalize the spread of output values % preprocessing face images....... im1=double(imgRaw); img = preproc2(im1,gamma,sigma0,sigma1,[sx,sy],mask,do_norm);
preproc2.m
function im = preproc2(im,gamma,sigma0,sigma1,shift,mask,do_norm) % Gamma correct input image to increase local contrast in shadowed % regions. if gamma == 0 im = log(im+max(1,max(max(im)))/256); else im = im.^gamma; end % run prefilter, if any if sigma1 border=1; if border % add extend-as-constant image border to reduce % boundary effects [m,n] = size(im); b=floor(3*abs(sigma1)); c=ones(b); d=ones(b,1); im = [ c*im(1,1), d*im(1,:), c*im(1,n);... im(:,1)*d', im, im(:,n)*d';... im(m,1)*c, d*im(m,:), c*im(m,n) ]; end if sigma1>0 % Build difference of gaussian filter and apply it to image. [x,y,r] = fftcoord(size(im,1),size(im,2)); g0 = exp(-0.5*(r/max(sigma0,1e-6)).^2); g0 = g0./sum(sum(g0)); g1 = exp(-0.5*(r/max(sigma1,1e-6)).^2); if ~isempty(shift) g1 = circshift(g1,shift); end g1 = g1./sum(sum(g1)); im = real(ifft2(fft2(im).*fft2(g0-g1))); else % sigma1<0, alternative implementation using explicit convolution if sigma0>0 im = gaussianfilter(im,sigma0)-gaussianfilter(im,-sigma1,shift); else im = im-gaussianfilter(im,-sigma1,shift); end end if border im = im(b+(1:m),b+(1:n)); end end if ~isempty(mask) % mask out unwanted pixels im=im.*mask; end if do_norm a = 0.1; trim = abs(do_norm); im = im./mean(mean(abs(im).^a))^(1/a); im = im./mean(mean(min(trim,abs(im)).^a))^(1/a); if do_norm>0 % trim/squash any large outliers (e.g. specularities) if % required. Can be omitted if your descriptor / image % display method is not sensitive to these. % im = min(trim,max(-trim,im)); % truncate im = trim*tanh(im/trim); % squash with tanh sigmoid end end % end
gaussianfilter.m
function imgResult=gaussianfilter(img,sigma,shift) if max(size(sigma))==1, sigma=[sigma sigma]; end if nargin<3 || isempty(shift), shift = 0; end if max(size(shift)) == 1, shift=[shift shift]; end %x = [floor(-3.0*sigma+0.5):floor(3.0*sigma+0.5)]; Gx = gauss([ceil(-3.0*sigma(1)-0.5-shift(1)):floor(3.0*sigma(1)+0.5-shift(1))],sigma(1)); Gy = gauss([ceil(-3.0*sigma(2)-0.5-shift(2)):floor(3.0*sigma(2)+0.5-shift(2))],sigma(2)); imgTmp = conv2(img,Gx,'same'); imgResult = conv2(imgTmp,Gy','same'); end
gauss.m
function G=gauss(x,sigma) %G = exp(-x.^2/(2*sigma^2))/(sqrt(2*pi)*sigma); G = exp(-x.^2/(2*sigma^2)); G=G/sum(sum(G)); end
fftcoord.m
% matrices with x,y and radial frequency coordinates of corresponding % entry of fft matrix function [x,y,r] = fftcoord(m,n) if nargin<2 m2 = ceil(m/2); x = [0:m2-1,m2-m:-1]; else m2 = ceil(m/2); n2 = ceil(n/2); x = ([0:m2-1, m2-m:-1])'*ones(1,n); if nargout>=2 y = ones(m,1)*([0:n2-1, n2-n:-1]); if nargout>=3 r = sqrt(x.^2+y.^2); % r(1,1) = 1e-8; end end end % end
调用方式:
src输入为灰度图像: dst = psTan(src);
相关文章推荐
- Python opencv2 人脸识别
- 基于OpenCV的简单的人脸检测
- 在Android中播放音频和视频--值得学习
- 模式识别 学习笔记:第八章 特征提取
- 人脸识别
- 人脸识别---LBP特征与高维LBP特征
- 人脸识别---排序测度特征(Ordinal Measures)
- ios OpenCv的配置和人脸识别技术
- Deep Convolutional Network Cascade for Facial Point Detection阅读笔记
- Facebook研究出接近人类水平的脸部识别技术
- 谁是真痛谁在装?计算机的识别能力已远超人类
- PAM脸部识别登录ubuntu
- OpenCV+Dlib进行实时脸部检测
- 7行Python代码的人脸识别
- Qt5.7+Opencv2.4.9人脸识别(一)项目介绍
- SeetaFaceEngine安装和测试
- Qt+Caffe+OpenCV——【一个基于VGG网络的人脸识别考勤系统】
- Opencv与dlib联合进行人脸关键点检测与识别
- 人脸识别总结
- python基于openCV3的人脸识别