当前位置:网站首页>最远点采样 — D-FPS与F-FPS
最远点采样 — D-FPS与F-FPS
2022-07-30 07:41:00 【Coding的叶子】
点云最远点采样FPS(Farthest Point Sampling)方法的优势是可以尽可能多地覆盖到全部点云,但是需要多次计算全部距离,因而属于复杂度较高的、耗时较多的采样方法。
1 最远点采样(FPS)采样步骤
FPS采样步骤为:
(1)选择一个初始点:可以随机选择,也可以按照一定的规则来选取。如果随机选取那么每次得到的结果都是不一样的,反之每次得到的结果就是一致的。
(2)计算所有点与(1)中点的距离,选择距离最大的值作为新的初始点。
(3)重复前两步过程,知道选择的点数量满足要求。
由于(2)中每次选择的距离都是最大的,所以迭代的过程距离最大值会逐渐减少。这也就是下面代码中mask选取的依据。如果把加这一个限制,那么点会被来回重复选到。
2 距离最远点采样(D-FPS)
上述最远点采样通过计算点与点的之间距离来进行取样。距离最远点采样是指计算点与点之间的坐标距离,通常取xyz三个坐标。
# -*- coding: utf-8 -*-
"""
乐乐感知学堂公众号
@author: https://blog.csdn.net/suiyingy
参考:https://github.com/yanx27/Pointnet_Pointnet2_pytorch
"""
import numpy as np
def farthest_point_sample(point, npoint):
"""
Input:
xyz: pointcloud data, [N, D]
npoint: number of samples
Return:
centroids: sampled pointcloud index, [npoint, D]
"""
N, D = point.shape
xyz = point[:,:3]
centroids = np.zeros((npoint,))
distance = np.ones((N,)) * 1e10
farthest = np.random.randint(0, N)
for i in range(npoint):
centroids[i] = farthest
centroid = xyz[farthest, :]
dist = np.sum((xyz - centroid) ** 2, -1)
mask = dist < distance
distance[mask] = dist[mask]
farthest = np.argmax(distance, -1)
point = point[centroids.astype(np.int32)]
return point3 特征最远点采样(F-FPS)
上述最远点采样通过计算点与点的之间距离来进行取样。特征最远点采样是指计算点的特征之间的距离。假设每个点的坐标为xyz 3个维度,输入特征为M个维度。特征最远点采样计算距离时经常会将xyz坐标与特征进行拼接作为新的特征,然后计算特征之间的距离,以进行最远点采样。
# -*- coding: utf-8 -*-
"""
乐乐感知学堂公众号
@author: https://blog.csdn.net/suiyingy
参考:https://github.com/yanx27/Pointnet_Pointnet2_pytorch
"""
import numpy as np
def farthest_point_sample(point, npoint):
"""
Input:
xyz: pointcloud data, [N, D]
npoint: number of samples
Return:
centroids: sampled pointcloud index, [npoint, D]
"""
N, D = point.shape
xyz = point
centroids = np.zeros((npoint,))
distance = np.ones((N,)) * 1e10
farthest = np.random.randint(0, N)
for i in range(npoint):
centroids[i] = farthest
centroid = xyz[farthest, :]
dist = np.sum((xyz - centroid) ** 2, -1)
mask = dist < distance
distance[mask] = dist[mask]
farthest = np.argmax(distance, -1)
point = point[centroids.astype(np.int32)]
return point4 【python三维深度学习】python三维点云从基础到深度学习_Coding的叶子的博客-CSDN博客_python 三维点云
边栏推荐
- 【网络攻防】常见的网络攻防技术——黑客攻防(通俗易懂版)
- linux安装mysql8参考指引
- SQL row-column conversion
- typescript6 - simplify the steps to run ts
- 阿里云国际版云服务器防火墙设置
- Fix datagrip connection sqlserver error: [08S01] The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption.
- Delphi仿制Web的导航
- The blockbuster IP that has been popular in the world for 25 years, the new work has become a script paradise
- mysql8的my.conf配置文件参考指引
- 【微信小程序】页面事件
猜你喜欢
随机推荐
「活动推荐」探索未来:数字科技
C语言力扣第46题之全排列。回溯法
41.【vector应用操作2】
【Kotlin 中的类和继承】
Alibaba Cloud Cloud Server Firewall Settings
函数(1)
taro package compilation error
svn中文路径 权限设定
【Flask框架①】——Flask介绍
SQL窗口函数
一文带你玩转offer-01
Lenovo Notebook How to Change Windows 10 Boot Logo Icon
typescript5 - compile and install ts code
test3
保存在 redis中的token 如何续期?
stack containing min function (js)
JS中对事件流的理解
redis伪集群搭建
typescript3-ts对比js的差别
LeetCode:647. 回文子串









