我正在研究从激光雷达接收到的三维点云。我用Axes3D.voxels
方法将大量的点(高达1千万到1亿)分割成立方体,研究它们的位置并在一个单独的体素中显示结果。但是,在多次使用此方法之后,在设置Axes3D
的适当限制时,我面临一些问题。你知道吗
我定义add_voxels
函数,以便从输入的立方体的np.array
位置立即显示体素:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import itertools
def add_voxels(true_ids, ax):
shape_of_filled = true_ids.max(axis=0) + 1 # shape of building
filled = np.zeros(shape_of_filled)
for n in true_ids:
filled[n] = 1
x, y, z = np.indices(np.array(shape_of_filled) + 1)
return ax.voxels(x,y,z, filled)```
Then use it to plot my two clouds of cubes:
fig = plt.gcf() # get a reference to the current figure instance
ax = fig.gca(projection='3d') # get a reference to the current axes instance
cubecloud1 = np.array(list(itertools.product(range(2,4), range(2,4), range(2,4))))
cubecloud2 = np.array(list(itertools.product(range(4,7), range(4,7), range(4,7))))
add_voxels(cubecloud2, ax)
add_voxels(cubecloud1, ax)
plt.show()
它会导致体素位置显示的不好限制:
https://i.imgur.com/2wXJKVF.png
我希望所有组件都显示在正确的边界框中,如下所示:
https://i.imgur.com/MZXh3O8.png
或者,至少是这样(假设边界框也包含不可见的体素):
我只能通过明确设置轴限制来实现这一点:
相关问题 更多 >
编程相关推荐