绘制点云图时用颜色来表征其高度, 我们先计算了点云的高度范围,然后把每个点的颜色根据高度来进行映射
稍微修改代码,我们也可以让高度颜色渐变转换为 X 轴距离颜色渐变:
稍微修改代码,我们也可以让高度颜色渐变转换为 X 轴距离颜色渐变:
文章来源:https://www.toymoban.com/news/detail-624754.html
# coding:utf-8
import numpy as np
import open3d as o3d
cloud = o3d.io.read_point_cloud("kitti_p.pcd")
pts = np.asarray(cloud.points)
# 根据高度生成色彩
colors = np.zeros([pts.shape[0], 3])
height_max = np.max(pts[:, 2])
height_min = np.min(pts[:, 2])
delta_c = abs(height_max - height_min) / (255 * 2)
for j in range(pts.shape[0]):
color_n = (pts[j, 2] - height_min) / delta_c
if color_n <= 255:
colors[j, :] = [0, 1 - color_n / 255, 1]
else:
colors[j, :] = [(color_n - 255) / 255, 0, 1]
cloud.colors = o3d.utility.Vector3dVector(colors)
o3d.visualization.draw_geometries([cloud], window_name="wechat 394467238 ")
文章来源地址https://www.toymoban.com/news/detail-624754.html
到了这里,关于根据点云高度赋色(附open3d python代码)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!