我想从网格中删除存储在NumPy数组中的一些顶点。如何根据顶点索引或坐标在pymeshlab中选择这些顶点?谢谢!
import pymeshlab
from scipy.spatial import KDTree
def remove_background(subdir, ms):
# load joint points
joint_arr = load_joint_points(subdir)
# get a reference to the current mesh
m = ms.current_mesh()
# get numpy arrays of vertices of the current mesh
vertex_array_matrix = m.vertex_matrix()
print(f'total # of vertices: {m.vertex_number()}')
# create a KD tree of the joint points
tree = KDTree(joint_arr)
selected_vertices = []
for vertex in vertex_array_matrix:
# if the closest joint pt is farther than 500mm from the vertex, add the vertex to list
dd, ii = tree.query(vertex, k=1)
if(dd > 500):
selected_vertices.append(vertex)
print(f"delete {len(selected_vertices)} vertices")
#how to select 'selected vertices' in pymeshlab?
ms.delete_selected_vertices()发布于 2021-07-21 08:18:14
,!可以使用使用条件选择滤波器的索引有条件地选择顶点。
import pymeshlab as ml
ms = ml.MeshSet()
# just create a simple mesh for example
ms.sphere(subdiv=0)
# select the vertex with index 0
ms.conditional_vertex_selection(condselect="vi==0")
# delete selected stuff
ms.delete_selected_vertices() 更好的是,你可以做所有的背景移除在肉糜室内。如果您有两个网格/点云( A B ),并且希望从B中删除所有接近A的顶点(小于给定阈值),则只需加载两个网格,就可以使用Hausdorff距离滤波器,它将存储到A的每个顶点的“质量”中--距离E 113B<代码>E 214的最近顶点的距离;然后,您可以通过测试质量再次使用条件选择筛选器。
https://stackoverflow.com/questions/68417158
复制相似问题