码迷,mamicode.com
首页 > 其他好文 > 详细

Hausdorff距离—曲线/点集间距离度量

时间:2015-08-28 13:24:18      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:曲线距离   hausdorff   点集距离   

技术分享

技术分享

技术分享



技术分享


附改进版代码,未改进版只要稍作改动即是。

function [ mhd ] = ModHausdorffDist( A, B )

% A -> Point set 1
% B -> Point set 2

% No. of samples of each point set may be different but the dimension of
% the points must be the same.

% Compute the sizes of the input point sets
Asize = size(A);
Bsize = size(B);

% Check if the points have the same dimensions
if Asize(2) ~= Bsize(2)
    error('The dimensions of points in the two sets are not equal');
end

% Calculating the forward HD

fhd = 0;                    % Initialize forward distance to 0
for a = 1:Asize(1)          % Travel the set A to find avg of d(A,B)
    mindist = Inf;          % Initialize minimum distance to Inf
    for b = 1:Bsize(1)      % Travel set B to find the min(d(a,B))
        tempdist = norm(A(a,:)-B(b,:));
        if tempdist < mindist
            mindist = tempdist;
        end
    end
    fhd = fhd + mindist;    % Sum the forward distances
end
fhd = fhd/Asize(1);         % Divide by the total no to get average

% Calculating the reverse HD

rhd = 0;                    % Initialize reverse distance to 0
for b = 1:Bsize(1)          % Travel the set B to find avg of d(B,A)
    mindist = Inf;          % Initialize minimum distance to Inf
    for a = 1:Asize(1)      % Travel set A to find the min(d(b,A))
        tempdist = norm(A(a,:)-B(b,:));
        if tempdist < mindist
            mindist = tempdist;
        end
    end
    rhd = rhd + mindist;    % Sum the reverse distances
end
rhd = rhd/Bsize(1);         % Divide by the total no. to get average

mhd = max(fhd,rhd);         % Find the minimum of fhd/rhd as 
                            % the mod hausdorff dist

end



版权声明:本文为博主原创文章,未经博主允许不得转载。

Hausdorff距离—曲线/点集间距离度量

标签:曲线距离   hausdorff   点集距离   

原文地址:http://blog.csdn.net/xingyanxiao/article/details/48048613

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!