이 번역 페이지는 최신 내용을 담고 있지 않습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.
라이다 포인트 클라우드 데이터 읽기, 처리하기, 쓰기
R2026a이 예제에서는 포인트 클라우드를 작업 공간으로 읽어오고 원하는 일련의 점들을 선택한 다음 선택한 점들을 포인트 클라우드 파일 형식에 쓰는 방법을 보여줍니다.
1단계: 포인트 클라우드 읽기 및 표시하기
lasFileReader 함수를 사용하여 .las 파일의 데이터를 작업 공간으로 읽어옵니다. 출력 lasFileReader 객체에 저장된 속성을 표시합니다.
fileName = fullfile(toolboxdir("lidar"),"lidardata","las","aerialLidarData.laz"); lasReader = lasFileReader(fileName)
lasReader =
lasFileReader with properties:
Count: 1018047
XLimits: [4.2975e+05 4.3015e+05]
YLimits: [3.6798e+06 3.6801e+06]
ZLimits: [72.7900 125.8200]
Attributes: ["Classification" "LaserReturn" "NumReturns" "ScanDirectionFlag" "EdgeOfFlightLineFlag" "ScanAngle" "UserData" "PointSourceID" "GPSTimeStamp"]
ClassificationInfo: "To get the value, enter lasReader.ClassificationInfo at the Command Window. Learn more"
LaserReturnInfo: [4×2 table]
VariableLengthRecords: [3×3 table]
Show all properties
.las 파일에서 포인트 클라우드를 읽어옵니다.
ptCloud = readPointCloud(lasReader);
포인트 클라우드를 표시합니다.
fig = figure(Position=[0 0 800 400]); hPanel = uipanel(fig); hPlot = axes(hPanel); pcshow(ptCloud.Location,Parent=hPlot)

2단계: 원하는 일련의 점들을 선택하기
객체 클래스에 대한 분류 값과 ROI(관심 영역) 내 점들의 인덱스를 지정하여 입력 포인트 클라우드에서 원하는 일련의 점들을 선택할 수 있습니다.
분류 값을 지정하여 점 선택하기
분류 값을 지정하여 점들을 선택하려면,
lasFileReader객체의ClassificationInfo속성을 사용하여 입력 포인트 클라우드에서 객체 클래스에 대한 정보를 읽어옵니다.
disp(lasReader.ClassificationInfo)
Classification Value Class Name Number of Points by Class
____________________ ___________________ _________________________
1 "Unclassified" 114842
2 "Ground" 646632
4 "Medium Vegetation" 210101
6 "Building" 45699
8 "Reserved(8)" 751
9 "Water" 22
readpointCloud함수를 사용하여 입력 포인트 클라우드에서 읽어올 객체 클래스에 대한 분류 값을 지정합니다. 중간 정도의 초목 영역에 대응하는 점들을 읽어오려면Classification이름-값 인수에 대한 값을 4로 설정합니다.
ptCloudB = readPointCloud(lasReader,Classification=4);
포인트 클라우드를 표시합니다.
fig1 = figure(Position=[0 0 800 400]); hPanel1 = uipanel(fig1); hPlot1 = axes(hPanel1); pcshow(ptCloudB.Location,Parent=hPlot1)

인덱스를 지정하여 점 선택하기
입력 포인트 클라우드의 x, y, z 좌표의 범위 내에서 직육면체 ROI를 정의합니다.
roi = [lasReader.XLimits(1)+200, lasReader.XLimits(2), ...
lasReader.YLimits(1), lasReader.YLimits(2), lasReader.ZLimits(1), lasReader.ZLimits(2)];직육면체 ROI 범위 내에 있는 점들의 인덱스를 구합니다.
indices = findPointsInROI(ptCloudB,roi);
직육면체 ROI 범위 내에 있는 점들을 선택하고 point cloud 객체로 저장합니다.
ptCloudC = select(ptCloudB,indices);
포인트 클라우드를 표시합니다.
fig2 = figure(Position=[0 0 800 400]); hPanel2 = uipanel(fig2); hPlot2 = axes(hPanel2); pcshow(ptCloudC.Location,Parent=hPlot2)

3단계: 선택한 점들을 .las 파일 형식에 쓰기
.las 파일의 이름을 지정하고 lasFileWriter 객체를 만듭니다.
newfileName = "aerialvegetation.las";
lasWriter = lasFileWriter(newfileName);writePointCloud 함수를 사용하여, 선택한 점들을 .las 파일에 씁니다. 이 함수는 현재 작업 디렉터리에 새 파일을 만듭니다.
writePointCloud(lasWriter,ptCloudC);
4단계: 새로 쓴 파일의 속성 확인하기
newlasReader = lasFileReader(newfileName)
newlasReader =
lasFileReader with properties:
Count: 116598
XLimits: [4.2995e+05 4.3015e+05]
YLimits: [3.6798e+06 3.6801e+06]
ZLimits: [84.9500 123.1100]
Attributes: ["Classification" "LaserReturn" "NumReturns" "ScanDirectionFlag" "EdgeOfFlightLineFlag" "ScanAngle" "UserData" "PointSourceID" "GPSTimeStamp" "ScannerChannel"]
ClassificationInfo: "To get the value, enter newlasReader.ClassificationInfo at the Command Window. Learn more"
LaserReturnInfo: [1×2 table]
VariableLengthRecords: [1×3 table]
Show all properties
참고 항목
lasFileReader | pcshow | readPointCloud | findPointsInROI | pointCloud (Computer Vision Toolbox) | select