我正在使用skimage.measure.marching_cubes提取一个曲面,定义为faces和vertices。marching_cubes还会为每个面输出values。
如何“平滑”这些values (实际的平滑可以是低通滤波器、中值滤波器等)?我认为实现这一点的一种方法是投影,或者在2D中表示这个曲面,然后应用标准过滤器,但我不能从面和顶点的列表中想到如何做到这一点。
这种“平滑”的原因是,这些值在曲面的单个面的比例上并不是信息丰富的,而是在由多个面表示的更大的曲面区域上。
提前感谢!
发布于 2018-07-05 17:41:34
我最终找到了一种方法,基于本文中的MATLAB代码:
Welf等人。《受控3D微环境中的定量多尺度细胞成像》,《Developmental Cell》,2016,36卷,第4期,p462-475
def median_filter_surface(faces, verts, measure, radius, p_norm=2):
from scipy import spatial
import numpy as np
# INPUT:
# faces: triangular surface faces - defined by 3 vertices
# verts: the above vertices, defined by x,y,z coordinates
# measure: the value related to each face that needs to be filtered
# radius: the radius for median filtering (larger = more filtering)
# p_norm: distance metric for the radius, default 2 (euclidian)
# OUTPUT:
# measure_med_filt: the "measure" after filtering
num_faces = len(faces)
face_centres = np.zeros((num_faces, 3))
# get face centre positions in 3D space (from vert coordinates)
for face in range(0, num_faces):
face_centres[face, :] = np.mean(verts[faces[face, :], :], 0)
# return all other points within a radius
tree = spatial.KDTree(face_centres)
faces_in_radius = tree.query_ball_point(face_centres, radius, p_norm)
measure_med_filt = np.zeros(len(faces))
for face in range(0, len(faces)):
measure_med_filt[face] = np.median(measure[faces_in_radius[face]])
return measure_med_filthttps://stackoverflow.com/questions/50723316
复制相似问题