python三维网格图_python-3D网格之间的Hausdorff距离
我在这里是新人,但面临同样的挑战,并试图直接在3D级别上对其进行攻击.
所以这是我做的功能:
def Hausdorff_dist(vol_a,vol_b):
dist_lst = []
for idx in range(len(vol_a)):
dist_min = 1000.0
for idx2 in range(len(vol_b)):
dist= np.linalg.norm(vol_a[idx]-vol_b[idx2])
if dist_min > dist:
dist_min = dist
dist_lst.append(dist_min)
return np.max(dist_lst)
输入的内容必须是numpy.array,其余的则可以直接使用.
我有8000个vs.5000个3D点,它运行了几分钟,但最终到达了您要寻找的距离.
但是,这是在检查两个点之间的距离,而不是两个曲线的距离. (都不是网格).
编辑(2015年11月26日):
最近完成了此代码的微调版本.现在将其分为两部分.
首先是注意在给定点周围抓住一个盒子,并取走所有半径.我认为这是减少检查所需点数的明智方法.
def bbox(array, point, radius):
a = array[np.where(np.logical_and(array[:, 0] >= point[0] - radius, array[:, 0] <= point[0] + radius))]
b = a[np.where(np.logical_and(a[:, 1] >= point[1] - radius, a[:, 1] <= point[1] + radius))]
c = b[np.where(np.logical_and(b[:, 2] >= point[2] - radius, b[:, 2] <= point[2] + radius))]
return c
以及其他用于距离计算的代码:
def hausdorff(surface_a, surface_b):
# Taking two arrays as input file, the function is searching for the Hausdorff distane of "surface_a" to "surface_b"
dists = []
l = len(surface_a)
for i in xrange(l):
# walking through all the points of surface_a
dist_min = 1000.0
radius = 0
b_mod = np.empty(shape=(0, 0, 0))
# increasing the cube size around the point until the cube contains at least 1 point
while b_mod.shape[0] == 0:
b_mod = bbox(surface_b, surface_a[i], radius)
radius += 1
# to avoid getting false result (point is close to the edge, but along an axis another one is closer),
# increasing the size of the cube
b_mod = bbox(surface_b, surface_a[i], radius * math.sqrt(3))
for j in range(len(b_mod)):
# walking through the small number of points to find the minimum distance
dist = np.linalg.norm(surface_a[i] - b_mod[j])
if dist_min > dist:
dist_min = dist
dists.append(dist_min)
return np.max(dists)
python三维网格图_python-3D网格之间的Hausdorff距离相关推荐
- python热图_python – 使用matplotlib中的3D数据生成热图
我有一个函数returnValuesAtTime,它返回三个lists-x_vals,y_vals和swe_vals.所有三个列表具有相同的长度,并且swe_vals中的每个元素对应于来自x_vals ...
- Python中计算两个数据点之间的欧式距离,一个点到数据集中其他点的距离之和
计算数两个数据点之间的欧式距离 import numpy as np def ed(m, n):return np.sqrt(np.sum((m - n) ** 2)) i = np.array([1 ...
- Python爬取两个城市之间的直线距离
因需要爬取江浙沪皖地级市之间的城市距离,爬取的网址是http://www.china6636.com/.爬取代码如下: ###江浙沪皖41城市代号 x=[27005208,27017237,27029 ...
- python热图_Python 绘制热图
原博文 2019-09-03 16:50 − 1.matplitlib绘制热图 1 import random 2 from matplotlib import pyplot as plt 3 fro ...
- python热图_Python可视化matplotlibseborn14-热图heatmap
热力图(heatmap)可通过颜色深浅变化,优雅的展示数据的差异. 详细介绍python seaborn绘制热图 本文速览Matplotlib热图heatmapseaborn热图1seaborn热图2 ...
- python 六维图_Python 画出来六维图
来自维基百科 我们的大脑通常最多能感知三维空间,超过三维就很难想象了.尽管是三维,理解起来也很费劲,所以大多数情况下都使用二维平面. 不过,我们仍然可以绘制出空间,今天就来用 Python 的 plo ...
- python 字符图_python 字符画
教你利用Python把图片转字符画!代码哆啦A梦你见过嘛? 图片转字符画的关键是把图片的灰度值与自定义的字符集之间建立映射关系,不同区间的灰度值对应不同的字符,之后将图片每一个像素对应的字符打印出来, ...
- python大纲图_Python课程大纲
课程大纲被分成6个部分,每个部分又被分解为多个阶段, 而每个阶段包含了多个Try, Workshop, FactToFace, Apply. 这里只列出部分,和阶段: CHAPTER 0 : 预科[可 ...
- python龟图_python学习turtle(龟图标状态)
2019独角兽企业重金招聘Python工程师标准>>> 记录学习 turtle.hideturtle() turtle.ht(),隐藏龟图标. turtle.showturtle() ...
最新文章
- Linux7-常用文件管理命令及系统变量基础
- spoj Find Log
- 如何判断Javascript对象是否存在
- react把表格渲染好ui_《RSUITE》React企业级UI框架实战评测
- 基于Http替补新闻WebService数据交换
- C# 离线人脸识别 ArcSoft
- mvd没什么每次参数双都多一个逗号_必看!PostgreSQL参数优化
- SparkSql学习笔记(包含IDEA编写的本地代码)
- Centos-yum软件包安装-yum
- Quartz+Spring 自定义作业调度(作业在DB中配置)
- onclick 如何传数据_云主机文件传输神器:免占公网带宽,文件极速秒传
- CodeForces - 837F(二分组合思维)
- 彻底删除MySQL教程
- 基于java的网络电子通讯录的设计_网络电子通讯录管理系统
- Failed installing ‘Tomcat8‘ service?
- 宝塔服务器之堡塔应用管理器的使用【php消息队列】
- 51单片机 独立按键k1控制数码管移位 k2控制数值加
- please configure web facet first
- 服务器迁移实践,物理服务器迁移到阿里云服务器
- HDU oj wod sticks