深度学习中点云基本数据处理和增强方式,包括点云归一化、随机打乱、随机平移、随机旋转、随机缩放和随机丢弃等,持续总结与更新。

1 中心归一化

减去均值,并除以点距原点的最大距离。

def pc_normalize(pc):centroid = np.mean(pc, axis=0)pc = pc - centroidm = np.max(np.sqrt(np.sum(pc ** 2, axis=1)))pc = pc / mreturn pc

2 打乱点云顺序

def shuffle_data(data, labels):""" Shuffle data and labels.Input:data: B,N,... numpy arraylabel: B,... numpy arrayReturn:shuffled data, label and shuffle indices"""idx = np.arange(len(labels))np.random.shuffle(idx)return data[idx, ...], labels[idx], idxdef shuffle_points(batch_data):""" Shuffle orders of points in each point cloud -- changes FPS behavior.Use the same shuffling idx for the entire batch.Input:BxNxC arrayOutput:BxNxC array"""idx = np.arange(batch_data.shape[1])np.random.shuffle(idx)return batch_data[:,idx,:]

3 点云随机旋转

点云数据增强方式之一。

def rotate_point_cloud(batch_data):""" Randomly rotate the point clouds to augument the datasetrotation is per shape based along up directionInput:BxNx3 array, original batch of point cloudsReturn:BxNx3 array, rotated batch of point clouds"""rotated_data = np.zeros(batch_data.shape, dtype=np.float32)for k in range(batch_data.shape[0]):rotation_angle = np.random.uniform() * 2 * np.picosval = np.cos(rotation_angle)sinval = np.sin(rotation_angle)rotation_matrix = np.array([[cosval, 0, sinval],[0, 1, 0],[-sinval, 0, cosval]])shape_pc = batch_data[k, ...]rotated_data[k, ...] = np.dot(shape_pc.reshape((-1, 3)), rotation_matrix)return rotated_data#含法向量
def rotate_point_cloud_with_normal(batch_xyz_normal):''' Randomly rotate XYZ, normal point cloud.Input:batch_xyz_normal: B,N,6, first three channels are XYZ, last 3 all normalOutput:B,N,6, rotated XYZ, normal point cloud'''for k in range(batch_xyz_normal.shape[0]):rotation_angle = np.random.uniform() * 2 * np.picosval = np.cos(rotation_angle)sinval = np.sin(rotation_angle)rotation_matrix = np.array([[cosval, 0, sinval],[0, 1, 0],[-sinval, 0, cosval]])shape_pc = batch_xyz_normal[k,:,0:3]shape_normal = batch_xyz_normal[k,:,3:6]batch_xyz_normal[k,:,0:3] = np.dot(shape_pc.reshape((-1, 3)), rotation_matrix)batch_xyz_normal[k,:,3:6] = np.dot(shape_normal.reshape((-1, 3)), rotation_matrix)return batch_xyz_normal

4 z方向点云随机旋转

def rotate_point_cloud_z(batch_data):""" Randomly rotate the point clouds to augument the datasetrotation is per shape based along up directionInput:BxNx3 array, original batch of point cloudsReturn:BxNx3 array, rotated batch of point clouds"""rotated_data = np.zeros(batch_data.shape, dtype=np.float32)for k in range(batch_data.shape[0]):rotation_angle = np.random.uniform() * 2 * np.picosval = np.cos(rotation_angle)sinval = np.sin(rotation_angle)rotation_matrix = np.array([[cosval, sinval, 0],[-sinval, cosval, 0],[0, 0, 1]])shape_pc = batch_data[k, ...]rotated_data[k, ...] = np.dot(shape_pc.reshape((-1, 3)), rotation_matrix)return rotated_data

5  欧拉角随机旋转

可参考点云旋转平移章节。

def rotate_perturbation_point_cloud(batch_data, angle_sigma=0.06, angle_clip=0.18):""" Randomly perturb the point clouds by small rotationsInput:BxNx3 array, original batch of point cloudsReturn:BxNx3 array, rotated batch of point clouds"""rotated_data = np.zeros(batch_data.shape, dtype=np.float32)for k in range(batch_data.shape[0]):angles = np.clip(angle_sigma*np.random.randn(3), -angle_clip, angle_clip)Rx = np.array([[1,0,0],[0,np.cos(angles[0]),-np.sin(angles[0])],[0,np.sin(angles[0]),np.cos(angles[0])]])Ry = np.array([[np.cos(angles[1]),0,np.sin(angles[1])],[0,1,0],[-np.sin(angles[1]),0,np.cos(angles[1])]])Rz = np.array([[np.cos(angles[2]),-np.sin(angles[2]),0],[np.sin(angles[2]),np.cos(angles[2]),0],[0,0,1]])R = np.dot(Rz, np.dot(Ry,Rx))shape_pc = batch_data[k, ...]rotated_data[k, ...] = np.dot(shape_pc.reshape((-1, 3)), R)return rotated_data#含法向量
def rotate_perturbation_point_cloud_with_normal(batch_data, angle_sigma=0.06, angle_clip=0.18):""" Randomly perturb the point clouds by small rotationsInput:BxNx6 array, original batch of point clouds and point normalsReturn:BxNx3 array, rotated batch of point clouds"""rotated_data = np.zeros(batch_data.shape, dtype=np.float32)for k in range(batch_data.shape[0]):angles = np.clip(angle_sigma*np.random.randn(3), -angle_clip, angle_clip)Rx = np.array([[1,0,0],[0,np.cos(angles[0]),-np.sin(angles[0])],[0,np.sin(angles[0]),np.cos(angles[0])]])Ry = np.array([[np.cos(angles[1]),0,np.sin(angles[1])],[0,1,0],[-np.sin(angles[1]),0,np.cos(angles[1])]])Rz = np.array([[np.cos(angles[2]),-np.sin(angles[2]),0],[np.sin(angles[2]),np.cos(angles[2]),0],[0,0,1]])R = np.dot(Rz, np.dot(Ry,Rx))shape_pc = batch_data[k,:,0:3]shape_normal = batch_data[k,:,3:6]rotated_data[k,:,0:3] = np.dot(shape_pc.reshape((-1, 3)), R)rotated_data[k,:,3:6] = np.dot(shape_normal.reshape((-1, 3)), R)return rotated_data

6 指定角度旋转点云

def rotate_point_cloud_by_angle(batch_data, rotation_angle):""" Rotate the point cloud along up direction with certain angle.Input:BxNx3 array, original batch of point cloudsReturn:BxNx3 array, rotated batch of point clouds"""rotated_data = np.zeros(batch_data.shape, dtype=np.float32)for k in range(batch_data.shape[0]):#rotation_angle = np.random.uniform() * 2 * np.picosval = np.cos(rotation_angle)sinval = np.sin(rotation_angle)rotation_matrix = np.array([[cosval, 0, sinval],[0, 1, 0],[-sinval, 0, cosval]])shape_pc = batch_data[k,:,0:3]rotated_data[k,:,0:3] = np.dot(shape_pc.reshape((-1, 3)), rotation_matrix)return rotated_datadef rotate_point_cloud_by_angle_with_normal(batch_data, rotation_angle):""" Rotate the point cloud along up direction with certain angle.Input:BxNx6 array, original batch of point clouds with normalscalar, angle of rotationReturn:BxNx6 array, rotated batch of point clouds iwth normal"""rotated_data = np.zeros(batch_data.shape, dtype=np.float32)for k in range(batch_data.shape[0]):#rotation_angle = np.random.uniform() * 2 * np.picosval = np.cos(rotation_angle)sinval = np.sin(rotation_angle)rotation_matrix = np.array([[cosval, 0, sinval],[0, 1, 0],[-sinval, 0, cosval]])shape_pc = batch_data[k,:,0:3]shape_normal = batch_data[k,:,3:6]rotated_data[k,:,0:3] = np.dot(shape_pc.reshape((-1, 3)), rotation_matrix)rotated_data[k,:,3:6] = np.dot(shape_normal.reshape((-1,3)), rotation_matrix)return rotated_data

7 点云随机扰动

def jitter_point_cloud(batch_data, sigma=0.01, clip=0.05):""" Randomly jitter points. jittering is per point.Input:BxNx3 array, original batch of point cloudsReturn:BxNx3 array, jittered batch of point clouds"""B, N, C = batch_data.shapeassert(clip > 0)jittered_data = np.clip(sigma * np.random.randn(B, N, C), -1*clip, clip)jittered_data += batch_datareturn jittered_data

8 点云随机平移

def shift_point_cloud(batch_data, shift_range=0.1):""" Randomly shift point cloud. Shift is per point cloud.Input:BxNx3 array, original batch of point cloudsReturn:BxNx3 array, shifted batch of point clouds"""B, N, C = batch_data.shapeshifts = np.random.uniform(-shift_range, shift_range, (B,3))for batch_index in range(B):batch_data[batch_index,:,:] += shifts[batch_index,:]return batch_data

9 点云随机缩放

def random_scale_point_cloud(batch_data, scale_low=0.8, scale_high=1.25):""" Randomly scale the point cloud. Scale is per point cloud.Input:BxNx3 array, original batch of point cloudsReturn:BxNx3 array, scaled batch of point clouds"""B, N, C = batch_data.shapescales = np.random.uniform(scale_low, scale_high, B)for batch_index in range(B):batch_data[batch_index,:,:] *= scales[batch_index]return batch_data

10 点云随机丢弃

def random_point_dropout(batch_pc, max_dropout_ratio=0.875):''' batch_pc: BxNx3 '''for b in range(batch_pc.shape[0]):dropout_ratio =  np.random.random()*max_dropout_ratio # 0~0.875drop_idx = np.where(np.random.random((batch_pc.shape[1]))<=dropout_ratio)[0]if len(drop_idx)>0:batch_pc[b,drop_idx,:] = batch_pc[b,0,:] # set to the first pointreturn batch_pc

上述代码主要来源于GitHub - yanx27/Pointnet_Pointnet2_pytorch: PointNet and PointNet++ implemented by pytorch (pure python) and on ModelNet, ShapeNet and S3DIS.

python三维点云从基础到深度学习_Coding的叶子的博客-CSDN博客_3d点云 python从三维基础知识到深度学习,将按照以下目录持续进行更新。https://blog.csdn.net/suiyingy/article/details/124017716更多三维、二维感知算法和金融量化分析算法请关注“乐乐感知学堂”微信公众号,并将持续进行更新。

【点云预处理】10种点云数据数据预处理增强方法 — 持续总结和更新(一)相关推荐

  1. 【点云预处理】N种点云数据数据预处理方法 — 持续总结和更新(二)

    1~10种点云预处理方法请参考:10种点云数据数据预处理方法 - 持续总结和更新(一)_Coding的叶子的博客-CSDN博客_点云预处理.深度学习中点云基本数据处理和增强方式,包括点云归一化.随机打 ...

  2. html云文件系统,一种HTML5云文件系统

    一种HTML5云文件系统 胡岘 易晓东 戴华东 国防科技大学计算机学院 湖南 410073 摘要:本文提出了一种HTML5云文件系统,使得HTML5应用能够像访问传统文件系统一样访问云存储.HTML5 ...

  3. 如何利用阿里云赚钱_5种利用云赚钱的策略

    如何利用阿里云赚钱 现在每个人都在电视上听到云计算. 运营商会将您的联系人存储在云中. 托管公司将在云中托管您的网站. 其他人会将您的照片存储在云中. 但是,您如何利用云赚钱? 首先是忘记基础架构和虚 ...

  4. 10种你必须懂的PPT配色方法

    想完成一个让人眼前一亮的PPT,PPT的配色是少不了的,对于设计中的配色很多同学都是按自己的感觉来配,出来PPT设计作品往往是让人觉得怪,觉得不入流.想配出专业的颜色,那就从这篇文章来始吧,但开始讲1 ...

  5. 10种开发以及改善应用的低成本方法

    企业被要求开发出比以往更过的应用--并且是在更短的时间内.这里有10款工具和技术,能帮助你加快应用开发. 1.基于云的应用开发和测试 为了控制飙升的数据中心成本,很多企业开始将它们的应用开发和测试转移 ...

  6. 流体渐变_最新的10种Fluid Colors流体渐变壁纸制作方法

    大家好,我是UEgood的雪姐姐.随着iPhone X的到来,流体渐变的风格开始兴起,许多人都觉得这种风格特别漂亮,于是它一下子就火起来了.今天我们就来学习如何用流体渐变技术做漂亮的壁纸.当然,不止是 ...

  7. DEMO: 一种单目视觉里程计的深度增强方法

    点击上方"3D视觉工坊",选择"星标" 干货第一时间送达 作者:robot L | 来源:知乎 https://zhuanlan.zhihu.com/p/149 ...

  8. 科技云报道:发布分布式云战略,中国电子云吹响冲锋号角

    科技云报道原创. 过去三年,中国电子云一直牢牢抓住业界的目光,不仅因为"国家队"的身份光环,更因实打实的成绩令人侧目. 据悉,中国电子云核心产品中心云CECSTACK,起步可达30 ...

  9. 让工作变简单的10种方法

    "我从早忙到晚,但是没有一件事情是完成的.我这么拚命,结果却是白忙一场,没有什么成果.感觉自己一直被工作追着跑.我到底在忙些什么呢?"你的忙乱不是因为工作太多,而是因为没有重点.目 ...

  10. paddle 41 在paddledetection添加RotateScaleCopyPaste数据增强方法

    paddledetection中支持不少的数据增强方法,比如GridMask.Cutmix和MixUp等具体可以参考paddle 37 paddledetection中的数据增强方法.但是,缺失裁剪目 ...

最新文章

  1. 《head first java 》读书笔记(四)
  2. Observer 模式在eHR中的应用
  3. python的解释提示符为_python学习笔记01--基础
  4. 数据分析平台搭建案例
  5. LoaderManager使用详解(二)---了解LoaderManager
  6. HTML5与HTML4的比较
  7. C#LeetCode刷题之#53-最大子序和(Maximum Subarray)
  8. 防火墙阻止tftp_再谈突破TCP-IP过滤/防火墙进入内网(icmp篇)
  9. Sketch2AE插件(Sketch文件导入AE)最新破解版
  10. web版的在线绘图工具
  11. C++学习(一八一)android的NDK、SDK版本的对应关系
  12. 微信小程序开发学习5(自定义组件)
  13. windows10修改用户名解决CDK闪退问题
  14. 二叉树的中序遍历 递归与非递归
  15. 一个单点登录系统设计
  16. 修改flinksql已经定义表的表结构
  17. 根据日期计算星期几 -- 基姆拉尔森计算公式
  18. php基础(7)_运算符
  19. 计算机自考本科好还是it培训好,自考本科文凭有用吗|自考怎么样
  20. 计算机中腾讯QQ程序的安装路径,更改应用商店内应用的安装位置

热门文章

  1. SAP 查询分析器的实现的3种方法
  2. 广发银行网上银行安全控件官方版
  3. 股票自动交易软件API使用流程
  4. WinRunner的工作流程
  5. vb 服务器mysql_VB 连接mysql网络数据库的代码
  6. java 万年历接口
  7. ABAP 如何解析 JSON 数据试读版
  8. 用 ABAP 新建本地 Excel 文件并写入数据试读版
  9. a标签实现点击复制文本
  10. linux系统防火墙白名单,linux系统防火墙如何结束白名单