读取、处理和写入激光雷达点云数据
此示例演示如何将点云读入工作空间,选择所需的点集,然后将所选点写入点云文件格式。
步骤1:读取和显示点云
从又引线
将文件放入工作区中lasFileReader
函数。显示存储在输出中的属性lasFileReader
对象。
文件名= fullfile (toolboxdir (“激光雷达”),“lidardata”,“拉斯维加斯”,“aerialLidarData.laz”);lasReader = lasFileReader(文件名)
lasReader =具有如下属性的lasFileReader: ` /mathworks/dev /bat/Bdoc22b/build/matlab/toolbox/lidar/lidardata/las/aerialLidarData. FileName: `laz' Count: 1018047 LasVersion: '1.0' XLimits: [4.2975e+05 4.3015e+05] YLimits: [3.6798e+06 3.6801e+06] ZLimits: [72.7900 125.8200] GPSTimeLimits: [3.3355e+05 sec 3.3443e+05 sec] NumReturns: 4 NumClasses: 10 SystemIdentifier: ' lastols (c) by rapidlasso GmbH' GeneratingSoftware: 'TerraScan + OT' FileCreationDate: 28-Apr-2020 FileSourceID: 0 ProjectID: '0-0-0-00000000' PointDataFormat: 1 ClassificationInfo: [6x3表]LaserReturnInfo: [4x2表]VariableLengthRecords: [3x3表]
中读取点云又引线
文件。
ptCloud = readPointCloud (lasReader);
显示点云。
图=图(位置=[0 0 800 400]);hPanel = uipanel(图);hPlot =轴(hPanel);pcshow (ptCloud.Location、家长= hPlot)
步骤2:选择所需的点集
通过指定对象类的分类值和感兴趣区域(ROI)内点的索引,可以在输入点云中选择所需的点集。
通过指定分类值选择点
要通过指定分类值来选择点,请使用
ClassificationInfo
财产的lasFileReader
对象。
disp (lasReader.ClassificationInfo)
类名的分值类分类价值 ____________________ ___________________ _________________________ 114842“未分类”2“地面”4“中等植被“210101 6 646632”建设“45699 8“保留(8)”751 9“水
方法指定要从输入点云读取的对象类的分类值
readpointCloud
函数。若要读取中等植被区域对应的点,则设置为分类
名称-值参数为4。
ptCloudB = readPointCloud (lasReader、分类= 4);
显示点云。
fig1 = figure(Position=[0 0 800 400]);hPanel1 = uipanel(图一);hPlot1 =轴(hPanel1);pcshow (ptCloudB.Location、家长= hPlot1)
通过指定索引选择点
的范围内定义一个长方体ROIx,y而且z输入点云的坐标。
roi = [lasReader.XLimits(1)+200, lasReader.XLimits(2),...lasReader.YLimits(1), lasReader.YLimits(2), lasReader.ZLimits(1), lasReader.ZLimits(2)];
求出位于长方体ROI内的点的指数。
指数= findPointsInROI (ptCloudB roi);
选择位于长方体ROI内的点,并将其存储为点云对象。
ptCloudC =选择(ptCloudB、指标);
显示点云。
fig2 = figure(Position=[0 0 800 400]);hPanel2 = uipanel(图);hPlot2 =轴(hPanel2);pcshow (ptCloudC.Location、家长= hPlot2)
第三步:将选定的点写入。las文件格式
指定.las文件的名称,并创建一个lasFileWriter
对象。
newfileName =“aerialvegetation.las”;lasWriter = lasFileWriter (newfileName);
将选定的点写入又引线
文件,使用writePointCloud
函数。该函数在当前工作目录中创建新文件。
writePointCloud (lasWriter ptCloudC);
步骤4:检查新写入文件的属性
newlasReader = lasFileReader (newfileName)
newlasReader =具有如下属性的lasFileReader: '/tmp/Bdoc22b_2054784_2402794/tp21984494/lidar-ex04737654/aerialvegetation. `las' Count: 116598 LasVersion: '1.2' XLimits: [4.2995e+05 4.3015e+05] YLimits: [3.6798e+06 3.6801e+06] ZLimits: [84.9500 123.1100] gpstielimits: [0 sec 0 sec] NumReturns: 1 NumClasses: 1 SystemIdentifier: 'MATLAB' GeneratingSoftware: 'LASzip DLL 3.4 r1 (190411)' FileCreationDate: 30-Aug-2022 FileSourceID: 0 ProjectID: '0-0-0-00000000' PointDataFormat: 3 ClassificationInfo: [1x3表]LaserReturnInfo: [1x2表]VariableLengthRecords: [1x3表]
另请参阅
lasFileReader
|pcshow
|readPointCloud
|findPointsInROI
|pointCloud
|选择