PyVista:PolyData 的 3D 高斯平滑

问题描述 投票:0回答:1

我想使用我自己的数据复制这里的示例https://docs.pyvista.org/version/stable/examples/01-filter/gaussian-smoothing.html但尝试将

gaussian_smooth()
方法应用于我的
ImageData
结果为
MissingDataError: No data available.
(但适用于该示例)。我猜我需要将标量场传递给
ImageData
但我不确定我用什么属性来执行此操作。

一些可能有用的代码:

# create a uniform grid to sample the function with
n = 40
x_min, y_min, z_min = [np.min(q) - 0.25*np.absolute(np.min(q)) for q in [tmp[tmp[:,3]==1, 0], tmp[tmp[:,3]==1, 1], tmp[tmp[:,3]==1, 2]]]
x_max, y_max, z_max = [np.max(q) + 0.25*np.absolute(np.max(q)) for q in [tmp[tmp[:,3]==1, 0], tmp[tmp[:,3]==1, 1], tmp[tmp[:,3]==1, 2]]]
grid = pv.ImageData(
    dimensions=(n, n, n),
    spacing=( (x_max - x_min) / n, 
              (y_max - y_min) / n,
              (z_max - z_min) / n),
    origin=(x_min, y_min, z_min),
)

smooth_grid = grid.gaussian_smooth(std_dev=3.0)

我的问题:如何在我的

gaussian_smooth
 上成功执行 
ImageData

python 3d surface gaussianblur pyvista
1个回答
0
投票

这是从

ImageData
遍历到高斯平滑网格的最小可重现示例。

# Import packages
import numpy as np
import pyvista as pv

# Create an empty ImageData instance `grid`. [See here for more info.][1]
grid = pv.ImageData(dimensions=(10, 10, 10))

# Create random points to fill `grid`
rng = np.random.default_rng(seed=0)
points = rng.random((1000, 3))

# Fill `grid` with these random points
grid.point_data['mydata'] = points

# Gaussian smooth
grid_smoothed = grid.gaussian_smooth()
© www.soinside.com 2019 - 2024. All rights reserved.