def remove_close_set(points_fixed, points_reduce, radius):
'''
Given two sets of points and a radius, return a set of points
that is the subset of points_reduce where no point is within
radius of any point in points_fixed
'''
from scipy.spatial import cKDTree as KDTree
tree_fixed = KDTree(points_fixed)
tree_reduce = KDTree(points_reduce)
reduce_duplicates = tree_fixed.query_ball_tree(tree_reduce, r = radius)
reduce_duplicates = np.unique(np.hstack(reduce_duplicates).astype(int))
reduce_mask = np.ones(len(points_reduce), dtype=np.bool)
reduce_mask[reduce_duplicates] = False
points_clean = points_reduce[reduce_mask]
return points_clean
评论列表
文章目录