LDP算子 用于人脸识别()得到特征向量用于识别)
来源:互联网 发布:centos 6.5网络配置ip 编辑:程序博客网 时间:2024/06/15 23:32
<span style="font-size:18px;">I=imread('E:6.jpg');I=rgb2gray(I);[a b]=LDP(I,[1 1],2);</span>
<span style="font-size:18px;">% [HIST, LDPIM] = LDP(IMAGE, SUBSZ, ORDER) % Calculates the LDP images and histogram of IMAGE. The concatenation % of the LDP histograms of each subblock (of size SUBSZ) in the image% is returned in HIST, and the LDP code images are returned in LDPIM.% The LDP order is specified by ORDER.% This code is based on B Zhang, Y Gao, S Zhao & J Liu, "Local Derivative Pattern Versus Local Binary Pattern: Face Recognition With High-Order Local Pattern Descriptor," Image Processing, IEEE Transactions on, vol.19, no.2, pp.533,544, Feb. 2010function [hout,ldpim]=LDP(im, subsz, order)numBinsPerBlock = 32; % number of bins per direction per blockassert(order >=2 && order <= 10);assert(all(floor(size(im) ./ subsz(:)') == (size(im) ./ subsz(:)')));im = double(im);der0 = im;der45 = im;der90 = im;der135 = im;% calc derivative image of appropriate orderfor ii=2:order der0 = [der0(:, 1:end-1)-der0(:, 2:end) zeros(size(der0,1),1)]; % subtract right在最后一列不上0 der45 = [zeros(1,size(der45,2)); der45(2:end, 1:end-1)-der45(1:end-1, 2:end) zeros(size(der45,1)-1,1)]; % subtract above-right der90 = [zeros(1,size(der90,2)); der90(2:end, :)-der90(1:end-1, :)]; % subtract above der135 = [zeros(1,size(der135,2)); zeros(size(der135,1)-1,1) der135(2:end, 2:end)-der135(1:end-1, 1:end-1)]; % subtract above-leftend% calc LDP code using sign(dot product), combine adjacent codes to get 32 codes/binsdiv = 256 / numBinsPerBlock;% 分为多少分codes0 = floor(doDotProdCode(der0) / div);codes45 = floor(doDotProdCode(der45) / div);codes90 = floor(doDotProdCode(der90) / div);codes135 = floor(doDotProdCode(der135) / div);% make histograms for each subimage (block) within the code imagesbins = 0:numBinsPerBlock-1;hout = zeros(numBinsPerBlock * 4, prod(size(im) ./ subsz));hidx = 1;for ii=0:size(im,1)/subsz(1)-1 bii = ii*subsz(1) + (1:subsz(1)); for jj=0:size(im,2)/subsz(2)-1 bjj = jj*subsz(2) + (1:subsz(2)); block0 = codes0(bii, bjj); block45 = codes45(bii, bjj); block90 = codes90(bii, bjj); block135 = codes135(bii, bjj); hout(:, hidx) = [intHist(block0(:), bins) intHist(block45(:), bins) intHist(block90(:), bins) intHist(block135(:), bins)]';% hout(:, hidx) = [hist(block0(:), bins) hist(block45(:), bins) hist(block90(:), bins) hist(block135(:), bins)]'; hidx = hidx + 1; endendhout = hout(:);if nargout > 1ldpim.b0 = block0;ldpim.b45 = block45;ldpim.b90 = block90;ldpim.b135 = block135;endfigure(1)% show the derivative imagessubplot(221), imshow(der0,[]);subplot(222), imshow(der45,[]);subplot(223), imshow(der90,[]);subplot(224), imshow(der135,[]);figure(2)% showsubplot(221), imshow(codes0,[]);subplot(222), imshow(codes45,[]);subplot(223), imshow(codes90,[]);subplot(224), imshow(codes135,[]);endfunction yim=doDotProdCode(im)[m,n] = size(im);shim = zeros(m+2,n+2);shim(2:end-1, 2:end-1) = im; % zero-pad im%与八个方向的乘积dp1 = (shim(1:end-2,1:end-2) .* im) <= 0; % Z1 . Z0dp2 = (shim(1:end-2,2:end-1) .* im) <= 0; % Z2 . Z0dp3 = (shim(1:end-2,3:end) .* im) <= 0; % Z3 . Z0dp4 = (shim(2:end-1,3:end) .* im) <= 0; % Z4 . Z0dp5 = (shim(3:end,3:end) .* im) <= 0; % Z5 . Z0dp6 = (shim(3:end,2:end-1) .* im) <= 0; % Z6 . Z0dp7 = (shim(3:end,1:end-2) .* im) <= 0; % Z7 . Z0dp8 = (shim(2:end-1,1:end-2) .* im) <= 0; % Z8 . Z0yim = 1*dp1 + 2*dp2 + 4*dp3 + 8*dp4 + 16*dp5 + 32*dp6 + 64*dp7 + 128*dp8;end% note that all entries must belong to a value in bins, or it won't be% countedfunction ho=intHist(v, bins)ho = zeros(1,length(bins));for ii=1:length(bins) ho(ii) = sum(v == bins(ii));endend</span>
0 0
- LDP算子 用于人脸识别()得到特征向量用于识别)
- 人脸识别之特征向量
- LDN局部特征检测 (可以用于人脸检测 识别)
- AAM(Active Appreance Model)算法用于人脸识别总结
- AAM(Active Appreance Model)算法用于人脸识别总结
- Tensorflow实现卷积神经网络,用于人脸关键点识别
- Tensorflow实现卷积神经网络,用于人脸关键点识别
- Tensorflow实现卷积神经网络,用于人脸关键点识别
- 用于验证码图片识别的类(C#源码)
- 用于验证码图片识别的类(C#源码)
- 用于验证码图片识别的类(C#源码)
- 用于验证码图片识别的类(C#源码)
- 用于验证码图片识别的类(C#源码)
- 用于验证码图片识别的类(C#源码)
- SVM训练样本方法总结(用于目标识别)
- SVM训练样本方法总结(用于目标识别)
- 用于验证码图片识别的类(C#源码)
- linux (CentOS)安装python-tesseract 用于验证码识别
- SEO技巧学习:如何做最牛B的高质量外链接(超级效率的)?
- SRM 669 DIV 2 LiveConcert 250-point
- 有一个table表格,选中某一行后,点击“查看(button)”按钮可以实现对该行内容的显示
- LinearAlgebra_1
- LIVE555源码研究之MediaServer(转)
- LDP算子 用于人脸识别()得到特征向量用于识别)
- Spring data jpa高级查询,部分字段查询,过滤查询,空字符过滤
- leetcode 283--Move Zeroes
- 判断iOS设备的尺寸
- LeetCodeOJ.Longest Palindromic Substring
- dev(八):实战:使用udevadm修改usb优盘在/dev下的名字
- character_set_server
- JAVA JDBC 调用存储过程 传参数
- centos7 开机默认进入字符界面