Python实现点云投影到平面显示

作者:random_repick 时间:2021-05-10 14:51:15 

值得学习的地方:

1.选择合法索引的方式

2.数组转图像显示


import numpy as np
from PIL import Image

#input : shape(N, 4)
#    (x, y, z, intensity)
def pointcloud2image(point_cloud):
 x_size = 640
 y_size = 640
 x_range = 60.0
 y_range = 60.0
 grid_size = np.array([2 * x_range / x_size, 2 * y_range / y_size])
 image_size = np.array([x_size, y_size])
 # [0, 2*range)
 shifted_coord = point_cloud[:, :2] + np.array([x_range, y_range])
 # image index
 index = np.floor(shifted_coord / grid_size).astype(np.int)
 # choose illegal index
 bound_x = np.logical_and(index[:, 0] >= 0, index[:, 0] < image_size[0])
 bound_y = np.logical_and(index[:, 1] >= 0, index[:, 1] < image_size[1])
 bound_box = np.logical_and(bound_x, bound_y)
 index = index[bound_box]
 # show image
 image = np.zeros((640, 640), dtype=np.uint8)
 image[index[:, 0], index[:, 1]] = 255
 res = Image.fromarray(image)
 # rgb = Image.merge('RGB', (res, res, res))
 res.show()

来源:https://blog.csdn.net/random_repick/article/details/80770292

标签:Python,点云,投影,平面
0
投稿

猜你喜欢

  • ASP 验证码的程序及原理

    2010-04-24 15:56:00
  • Python pip 安装与使用(安装、更新、删除)

    2022-07-30 01:58:19
  • Asp中Server.ScriptTimeOut脚本超时属性需要注意的一点

    2008-10-18 14:53:00
  • python下载图片实现方法(超简单)

    2021-12-21 02:17:07
  • 详解Python中while无限迭代循环方法

    2022-08-17 12:53:48
  • python语法学习print中f-string用法示例

    2021-01-08 11:11:24
  • Python defaultdict方法使用分析

    2023-01-02 18:05:35
  • pycharm软件实现设置自动保存操作

    2022-09-01 00:02:15
  • python放大图片和画方格实现算法

    2023-05-21 15:22:41
  • WEB2.0网页制作标准教程(6)XHTML代码规范

    2007-12-13 13:03:00
  • sqlplus登录\\连接命令、sqlplus命令的使用大全

    2023-07-01 08:16:31
  • Python函数默认参数常见问题及解决方案

    2023-04-03 15:42:42
  • SQL临时表递归查询子信息并返回记录的代码

    2012-08-21 11:06:19
  • 客户端JavaScript代码封装

    2008-12-26 18:10:00
  • 详解Django模版中加载静态文件配置方法

    2023-11-16 19:55:13
  • python第三方库visdom的使用入门教程

    2021-12-08 22:32:51
  • linux中使用boost.python调用c++动态库的方法

    2023-01-19 19:21:03
  • 十几行的超简日历组件(兼容FF)js源码

    2010-08-08 08:49:00
  • 用python实现名片管理系统

    2022-03-27 09:34:33
  • pandas 取出表中一列数据所有的值并转换为array类型的方法

    2023-10-04 15:12:52
  • asp之家 网络编程 m.aspxhome.com