当前位置:网站首页>最远点采样 — 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 三维点云
边栏推荐
猜你喜欢

typescript8-类型注解

Splunk tag 的利用场景

一文带你玩转offer-01

立创EDA——PCB的走线(五)

【Flask框架②】——第一个Flask项目

SwiftUI SQLite 教程之 构建App本地数据库实现创建、读取、更新和删除(教程含完成项目源码)

Delphi仿制Web的导航

手把手教学OneOS FOTA升级

Selected as one of the "Top Ten Hard Core Technologies", explaining the technical points of Trusted Confidential Computing (TECC) in detail

你好,我的新名字叫 “铜锁 / Tongsuo”
随机推荐
代币(双代币)系统研究
智能存储柜——解决您的存储需求
typescript6 - simplify the steps to run ts
Selected as one of the "Top Ten Hard Core Technologies", explaining the technical points of Trusted Confidential Computing (TECC) in detail
保存在 redis中的token 如何续期?
Splunk tag 的利用场景
Risk Register
服务器可靠性稳定性调优指引
C# uses RestSharp to implement Get, Post requests (2)
C语言力扣第46题之全排列。回溯法
Why does typescript2-typescript add type support to js
test2
leetcode力扣——一篇文章解决多数之和问题
Detailed explanation of 4D words: C language three-point chess advanced + N-piece chess recursive dynamic judgment of winning or losing
求大佬解答,这种 sql 应该怎么写?
注解开发相关
潜心打磨,主动求变——这群技术排头兵,如何做好底层开发这件事?
[Mini Program Column] Summarize the development specifications of uniapp to develop small programs
SQL的substring_index()用法——MySQL字符串截取
[GAN]老照片修复Bringing Old Photos Back to Life论文总结