距离变换
来源:互联网 发布:装饰仿真模拟软件 编辑:程序博客网 时间:2024/05/09 15:30
距离变换
分类: Computer Vision2012-05-30 21:43 1317人阅读 评论(3) 收藏 举报
distance图像处理算法
距离变换和线性滤波器,形态学变换处于平等位置,是图像处理的一种方法,通过使用两遍扫描光栅算法可以快速计算到曲线或点集的距离。
应用:
水平集
快速斜切匹配
图像拼接
图像混合的羽化
临近点配准
方法:
首先对图像进行二值化处理,然后给每个像素赋值为离它最近的背景像素点与其距离(Manhattan距离or欧氏距离),得到distance metric(距离矩阵),那么离边界越远的点越亮。
实现:
- Imgori=imread('test.jpg');
- I=rgb2gray(Imgori);
- subplot(2,3,1);imshow(I);title('origin');
- Threshold=100;
- F=I>Threshold;%front
- %B=I<=Threshold;%background
- subplot(2,3,4);imshow(F,[]);title('binary');
- T=bwdist(F,'chessboard');
- subplot(2,3,2);imshow(T,[]);title('chessboard distance transform')
- %the chessboard distance between (x1,y1) and (x2,y2) is max(│x1 – x2│,│y1 – y2│).
- T=bwdist(F,'cityblock');
- subplot(2,3,3);imshow(T,[]);title('chessboard distance transform')
- %the cityblock distance between (x1,y1) and (x2,y2) is │x1 – x2│ + │y1 – y2│.
- T=bwdist(F,'euclidean');
- subplot(2,3,5);imshow(T,[]);title('euclidean distance transform')
- %use Euclidean distance
- T=bwdist(F,'quasi-euclidean');
- subplot(2,3,6);imshow(T,[]);title('quasi-euclidean distance transform')
- %use quasi-Euclidean distance
或者单纯想看这几个距离函数的区别可以用以下code:
- bw = zeros(200,200); bw(50,50) = 1; bw(50,150) = 1;
- bw(150,100) = 1;
- D1 = bwdist(bw,'euclidean');
- D2 = bwdist(bw,'cityblock');
- D3 = bwdist(bw,'chessboard');
- D4 = bwdist(bw,'quasi-euclidean');
- figure
- subplot(2,2,1), subimage(mat2gray(D1)), title('Euclidean')
- hold on, imcontour(D1)
- subplot(2,2,2), subimage(mat2gray(D2)), title('City block')
- hold on, imcontour(D2)
- subplot(2,2,3), subimage(mat2gray(D3)), title('Chessboard')
- hold on, imcontour(D3)
- subplot(2,2,4), subimage(mat2gray(D4)), title('Quasi-Euclidean')
- hold on, imcontour(D4)
- 距离变换
- 距离变换
- 距离变换
- 距离变换
- 距离变换
- 距离变换
- 距离变换
- 距离变换
- 距离变换
- 距离变换
- 距离变换
- 距离变换
- 距离变换
- 距离变换
- 距离变换
- 距离变换(cvDistTransform)
- 距离变换的理解
- Emgu 距离变换
- IOS学习笔记23—多线程之NSThread、NSOperation、NSInvocationOperation
- NHibernate OneToOne 映射下使用延迟加载
- 第4周-程序的多文件组织
- 高质量c/c++编程指南
- project euler Problem 39
- 距离变换
- 公用规则用升级版[3]Makefile 适用于中大型工程
- proj-1005 简单题
- IOS学习笔记27—使用GDataXML解析XML文档
- POJ2305:Basic remains
- 由模式谈对象对象的基本原则之依赖颠倒原则
- redis主从实现原理
- C/C++中extern关键字详解
- How to get Venue Coordinate of Foursquare