hausdorff distance and it's application to tile images classification

前段时间有会友发过求瓷砖图片分类的帖子,我看这是一个演示hausdorf距离的好例子,所以就发到这里来了。
hausdorf 距离的介绍请参考如下文献:
[1]   D. P. Huttenlocher, G. A. Klanderman, and W.  J. 
      Rucklidge, “Comparing  images using the Hausdorff 
      distance”,  IEEE  Trans. PAMI,  vol.  15, pp.  850- 
      863, 1993.
[2]  Marie-Pierre Dubisson and A.K.Jain. A modified hausdorff distance for
     object matching
这里用的是文献[2] modified hausdorff distance.
核心函数:
function d = m_hd(im1, im2)
%Effect: compute the modified haussdorff distance between 2 bw image 'im1'
%        and 'im2'
%inputs:
%im1, im2: bw image with the size
%outputs:
%d: the modified haussdorff distance between 'im1' & 'im2'
%Author: Su dongcai at 2012/1/11
%Email: suntree4152@gmail.com, qq:272973536
%reference:
%[1]   D. P. Huttenlocher, G. A. Klanderman, and W.  J. 
%      Rucklidge, “Comparing  images using the Hausdorff 
%      distance”,  IEEE  Trans. PAMI,  vol.  15, pp.  850- 
%      863, 1993.
%[2]  Marie-Pierre Dubisson and A.K.Jain. A modified hausdorff distance for
%     object matching

%0. check inputs:
im_sz1 = size(im1); im_sz2 = size(im2);
if(sum(abs(im_sz1-im_sz2))~=0)
    error('im1 and im2 must with the same size');
end
dist_im1 = bwdist(im1); dist_im2 = bwdist(im2);
pidx_im1 = find(im1); pidx_im2 = find(im2);
%eq.(6) in [2]
d12 = mean(dist_im1(pidx_im2));
d21 = mean(dist_im2(pidx_im1));
%eq.(8) in [2]
d = max(d12, d21);


结果演示:
splice_alltiles('.\tileImgs', '.\', 'splicedTiles_sort',100, 10, 10, [1:100]);
得到原始未分类图片:

[sort_idx, num_indv] = sortImgs('.\tileImgs', 100, 1.5);
splice_alltiles('.\tileImgs', '.\', 'splicedTiles_sort',100, 10, 10, sort_idx);
得到分类图片:

[local]2[/local]
num_indv =

    21    14    12    11     2     2    10    12     4     1     1     3     3     1     3
表示按列优先顺序(从上往下,从左往右),前21块砖为1类, 紧接着的14块砖为另一类,以此类推。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值