function mesh = pointCloud2mesh(data, refNormal, stdTol)
warning off MATLAB:divideByZero;
if nargin == 1
PC = pca(data);
data = data*PC;
refNormal = [0 0 1];
refNormal = refNormal * PC;
end
if nargin < 3
stdTol = 0.6;
end
tri = delaunay(data(:,1),data(:,2));
tri(:,4) = 0; % initialize 4th column to store maximum edge length
edgeLength = [sqrt(sum((data(tri(:,1),:) - data(tri(:,2),:)).^2,2)),...
sqrt(sum((data(tri(:,2),:) - data(tri(:,3),:)).^2,2)),...
sqrt(sum((data(tri(:,3),:) - data(tri(:,1),:)).^2,2))];
tri(:,4) = max(edgeLength,[],2);
resolution = mean(edgeLength(:));
stdeviation = std(edgeLength(:));
filtLimit = resolution + stdTol*stdeviation;
bigTriangles = find(tri(:,4) > filtLimit); %find index numbers of triagles with edgelength more than filtLimit
tri(bigTriangles,:) = []; % remove all triangles with edgelength more than filtlimit
tri(:,4) = []; % remove the max edgeLength column
edgeLength(bigTriangles,:) = []; % remove edges belonging to triangles which are removed
edgeLength = edgeLength(:);
resolution = mean(edgeLength); % find the mean of the remaining edges
stdeviation = std(edgeLength);
mesh = [];
if nargin < 2
data = data*PC';% multiply the data points by the inverse PC
refNormal = refNormal * PC';
end
mesh.vertices = data;
mesh.triangles = tri;
mesh.resolution = resolution;
mesh.stdeviation = stdeviation;
noOfpolygons = size(tri,1);
noOfpoints = size(data,1);
mesh.triangleNormals = zeros(noOfpolygons,3); % innitialize a matrix to store polygon normals
mesh.vertexNormals = zeros(noOfpoints,3); % innitialize a matrix to store point normals
mesh.vertexNtriangles = cell(noOfpoints, 1); %a cell array to store neighbouring polygons for the current point
mesh.triangleNtriangles = cell(noOfpolygons, 1); % to store neighbors of current polygon
for ii = 1:noOfpolygons %find normals of all polygons
%indices of the points from which the polygon is made
pointIndex1 = mesh.triangles(ii,1);
pointIndex2 = mesh.triangles(ii,2);
pointIndex3 = mesh.triangles(ii,3);
%coordinates of the points
point1 = mesh.vertices(pointIndex1,:);
point2 = mesh.vertices(pointIndex2,:);
point3 = mesh.vertices(pointIndex3,:);
vector1 = point2 - point1;
vector2 = point3 - point2;
normal = cross(vector1,vector2);
normal = normal / norm(normal);
theta = acos(dot(refNormal, normal));
if theta > pi/2
normal = normal * (-1);
a = mesh.triangles(ii,2);
mesh.triangles(ii,2) = mesh.triangles(ii,1);
mesh.triangles(ii,1) = a;
end
mesh.triangleNormals(ii,:)=normal;
%make entry of this polygon as the neighbouring polygon of the three
%vertex points
mesh.vertexNtriangles(pointIndex1,1)={[mesh.vertexNtriangles{pointIndex1,1} ii]};
mesh.vertexNtriangles(pointIndex2,1)={[mesh.vertexNtriangles{pointIndex2,1} ii]};
mesh.vertexNtriangles(pointIndex3,1)={[mesh.vertexNtriangles{pointIndex3,1} ii]};
end
for ii = 1:noOfpoints %find normals of all points
polys = mesh.vertexNtriangles{ii};% get neighboring polygons to this point
normal2 = zeros(1,3);
for jj = 1 : size(polys,1)
normal2 = normal2 + mesh.triangleNormals(polys(jj),:);
end
normal2 = normal2 / norm(normal2);
mesh.vertexNormals(ii,:) = normal2;
end
for ii = 1 : noOfpolygons % find neighbouring polygons of all polygons
polNeighbor = [];
for jj = 1 : 3
polNeighbor = [polNeighbor mesh.vertexNtriangles{mesh.triangles(ii,jj)}];
end
polNeighbor = unique(polNeighbor);
polNeighbor = setdiff(polNeighbor, [ii]);
mesh.triangleNtriangles(ii,1)={[polNeighbor]};
end
没有合适的资源?快使用搜索试试~ 我知道了~
matlab-基于matlab的三维点云数据的滤波处理,得到干净的目标点云数据-源码
共11个文件
m:7个
ply:2个
abs:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
4星 · 超过85%的资源 3 下载量 171 浏览量
2021-09-19
20:47:13
上传
评论
收藏 5.84MB RAR 举报
温馨提示
matlab_基于matlab的三维点云数据的滤波处理,得到干净的目标点云数据_源码
资源推荐
资源详情
资源评论
收起资源包目录
matlab_基于matlab的三维点云数据的滤波处理,得到干净的目标点云数据_源码.rar (11个子文件)
matlab_基于matlab的三维点云数据的滤波处理,得到干净的目标点云数据_源码
croppedEar.ply 933KB
rawEar.ply 7.71MB
Runme.m 2KB
mat3_ear
data_selected
02463d650.abs 12.66MB
02463d648.abs 12.63MB
func
pointCloud2mesh.m 4KB
absload.m 478B
inyrange.m 210B
inzrange.m 204B
inxrange.m 239B
makePly.m 709B
共 11 条
- 1
资源评论
- 卡西莫多2023-02-09一个文档还弄压缩包?
- tju55552021-10-03用户下载后在一定时间内未进行评价,系统默认好评。
- saya6666662022-04-25用户下载后在一定时间内未进行评价,系统默认好评。
mYlEaVeiSmVp
- 粉丝: 1880
- 资源: 19万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 80632180.jpg
- 李旭国体注入追踪[5.0](1).zip
- semantic.c
- C语言基础-C语言编程基础之Leetcode编程题解之第39题组合总和.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第38题外观数列.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第37题解数独.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第36题有效的数独.zip
- C语言基础-C语言编程基础之Leetcode编程题解之第35题搜索插入位置.zip
- index.wxml
- C语言基础-C语言编程基础之Leetcode编程题解之第33题搜索旋转排序数组.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功