资源简介
用matlab写的,采用doubly modified Hausdorff distance做人脸识别,识别率很高
代码片段和文件信息
function m2hd=MyM2HD(im1im2NP)
%Input: two normalised binary image: set1 set2they are of the same size
%Input: N is the size of neighborhoodsaythe width of the neighborhood is 2*N+1
%Input: P is the penalty
% tic;
m2hd=max(FM2HD(im1im2NP)FM2HD(im2im1NP));
% toc
function fm2hd=FM2HD(im1im2NP)
%Input: two normalised binary image: set1 set2they are of the same size
%Input: N is the size of neighborhoodsaythe width of the neighborhood is 2*N+1
%Input: P is the penalty
%Ouput: Forward M2HD from im1 to im2
[rc]=size(im2);
[point_r1pointc1]=find(im1>0);
[point_r2pointc2]=find(im2>0);
set1=[point_r1pointc1];
set2=[point_r2pointc2];
s1=size(set1);
s2=size(set2);
%计算im2中以各像素为中心的邻域内的所有像素之和,若和大于0,则说明在邻域中存在值为1的点
%由于FFT计算的是圆卷积,因此边缘点的计算可能会有错误
nb=real(ifft2(fft2(im2).*fft2(ones(2*N+1)rc)));%得到以im2中某一点为正方形邻域右下角(不是中心)内所有元素之和
nb=circshift(nb[-N-N]);%得到以im2中某一点为中心的邻域内所有元素之和
nb=(nb>=1);%提取im2中所有在以之为中心的邻域中有值为1的点的点
%计算min||a-b||s.t. b belongs to set2
% min1to2=zeros(s1(1)1);
% d1to2=zeros(s1(1)1);
% for i=1:s1(1)
% min1to2(i)=min(sqrt(sum((repmat(set1(i:)[s2(1) 1]) - set2).^22)));
% if nb(point_r1(i)pointc1(i))>0%如果set1中的点在im2中有邻近点
% d1to2(i)=min1to2(i);
% else
% d1to2(i)=P;
% end
% end
% fm2hd=sum(d1to2)/s1(1);
%%%%%%%%%%%% revised version %%%%%%%%%%%%%%%%%%%%
hasneighbor=im1.*nb;%提取im1中所有在im2中有邻近点的点
[hasrhasc]=find(hasneighbor>0);
hasnb=[hasrhasc];%im1中所有在im2中有邻近点的点的集合
sizehasnb=size(hasnb);
%对于在im2中有邻近点的点,d(aB)=min||a-b||s.t. b belongs to set2
minhasnb=zeros(sizehasnb(1)1);
for i=1:sizehasnb(1)
minhasnb(i)=min(sqrt(sum((repmat(hasnb(i:)[s2(1) 1]) - set2).^22)));
end
%compute the M2HD for the remaining points in set1 d(aB)=P
fm2hd=sum(minhasnb)+(s1(1)-sizehasnb(1))*P;
fm2hd=fm2hd/s1(1);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2046 2012-06-06 23:50 MyM2HD.m
文件 780 2012-06-05 09:30 MyMatch_M2HD.m
文件 782 2012-06-07 11:08 normalize.m
文件 896 2012-06-07 09:45 Sobel.m
文件 153 2012-06-03 00:05 SobelRGB.m
----------- --------- ---------- ----- ----
4657 5
- 上一篇:MIMO通信系统的设计与实现
- 下一篇:模拟高斯激光传播
评论
共有 条评论