简体   繁体   English

将3D点云转换为python上的二维网格图

[英]Converting 3D point cloud to a 2D gridmap on python

I have a 3d point cloud (x,y,z) and I want to get a 2d gridmap image, by projecting the point cloud into this gridmap.我有一个 3d 点云 (x,y,z),我想通过将点云投影到此网格图中来获得二维网格图图像。 Does anyone know how I can do that using Python?有谁知道我如何使用 Python 做到这一点?

Thank you!谢谢!

I created fake point cloud and used scipy's griddata:我创建了假点云并使用了 scipy 的网格数据:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.interpolate import griddata
d = np.random.randint(0, 35, (100, 3))
x = d[:, 0]
y = d[:, 1]
z = d[:, 2]
# grid size or so to say average distance between grid cells
avg_dist = 1.5
xi = np.arange(x.min(), x.max(), avg_dist)
yi = np.arange(y.min(), y.max(), avg_dist)
zi = griddata((x, y), z, (xi[None,:], yi[:,None]), method='linear')
# Visualization of the result
plt.figure(figsize=(12,6))
CS = plt.contour(xi,yi,zi,15,linewidths=0.11,colors='k')
CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.jet)
plt.colorbar(CS)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM