点云精简-基于曲率(MATLAB代码)

使用MATLAB实现点云精简,实验数据采用斯坦福兔子点云模型(bun000.ply),欢迎各位批评指正。

主要步骤如下:

1、计算各点K近邻内曲率

2、设置阈值筛选特征点

数据下载地址如下:

链接:https://pan.baidu.com/s/17JSVD40pSt6eqMrqkUx8qA?pwd=4zvo 
提取码:4zvo 
--来自百度网盘超级会员V5的分享

clc;
clear;
pc = pcread('bun000.ply');
pt=double(pc.Location);
count=pc.Count;
x=pt(:,1);
y=pt(:,2);
z=pt(:,3);
%%
K=50;
Thres=0.01;
%%
curvature=pccurvature(pc,K);
flag = zeros(count,1);
for i = 1:count
    if curvature(i)>Thres
        flag(i)=1;
    end
end
fprintf('精简比例为%d%%\n',round(100*length(find(flag==1))/count));
edge=boundary(x,y);
flag(edge,:)=1;
pt1=pt(flag==1,:);
%% 曲率精简
figure
pcshow(pt,"blue",viewPlane="XY",MarkerSize=5,BackgroundColor=[1 1 1],AxesVisibility=0)
img=gcf;
print(img, '-dpng', '-r300', ...
    'C:\Users\11607\Desktop\论文插图\曲率1.jpg')

figure
pcshow(pt1,"blue",ViewPlane="XY",MarkerSize=40,BackgroundColor=[1 1 1],AxesVisibility=0)
img=gcf;
print(img, '-dpng', '-r300', ...
    'C:\Users\11607\Desktop\论文插图\曲率2.jpg')

figure
pcshow(pt,curvature,ViewPlane="XY",MarkerSize=40,BackgroundColor=[1 1 1],AxesVisibility=0)
colormap sky
colorbar
img=gcf;
print(img, '-dpng', '-r300', ...
    'C:\Users\11607\Desktop\论文插图\曲率3.jpg')

function curvature=pccurvature(pc,K)
    count=pc.Count;
    pt=pc.Location;
    curvature = zeros(count,1);    
    for i = 1:count
        point=pt(i,:);
        [indices,~] = findNearestNeighbors(pc,point,K,'sort',true);
        KNNpoints=pt(indices,:);
        centroid = mean(KNNpoints,1);
        deMean = bsxfun(@minus,KNNpoints,centroid);
        H = 1/size(KNNpoints,1)*(deMean'*deMean);
        S = svd(H);%特征值
        curvature(i) = S(3)/sum(S);
        fprintf('%d\n',i)
    end
    clc
end

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值