距离地图库
distance-map的Python项目详细描述
距离图
Python距离地图库
对于N维(2≤N≤3)二元矩阵,返回相应的距离映射。 对于每个像素,该值等于到“正”像素的最小距离。 由于我计划使用这个库的方式,实现实际上是清晰的 在一个正点位置列表上,而不是二进制矩阵上。在
Δ = distance to nearest positive point
α = a user defined function (ℝ+ → ℝ+) (default : x ↦ x)
Ω = the maximum value
P_result(x, y) = min(α(Δ), Ω)
示例
用法
输入是一个积极点的列表
^{pr2}$输入是二进制(布尔)矩阵
distance_map_from_binary_matrix(input)
输入是一个正点的列表,您希望使用自定义参数
distance_map(input.shape, points, distance="manhattan", beta=15.0, alpha="square")
参数
- 距离
- 欧几里得
- 曼哈顿
- 阿尔法
- 身份(x↦x)
- 正方形(x↦x*x)
- 线性(x↦A*x+B)
- 使用set_a(a)和def set_b(b)更改a和b值
基准
下面的测试已经在一台搭载英特尔酷睿i7-7700HQ和24Go内存的笔记本电脑上进行。在
Test | Time distance_map | Time distance_map_from_binary_matrix |
---|---|---|
2D 1024 x 1024 image with 10 positive points | 8ms | 11ms |
2D 1024 x 1024 image with 5 positive points | 5ms | 9ms |
3D 128 x 128 x 128 image with 10 positive points | 61ms | 148ms |
确认
这个库的灵感来源于下面的文章。在
N. Xu, B. Price, S. Cohen, J. Yang and T. Huang
"Deep Interactive Object Selection"
2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR)
Las Vegas, NV, 2016, pp. 373-381
doi: 10.1109/CVPR.2016.47
- 项目
标签: