The three-dimensional point cloud data is projected onto the xoy plane and converted into a depth image (matlab code attached)

First, the three-dimensional coordinates (x, y, z) are extracted from the point cloud data.

Next, the code calculates the coordinate range of the point cloud data (the minimum and maximum values ​​​​of x, y, z), and the size of the image ( imageSize).

The code then converts the height difference by projecting the point cloud onto the xoy plane and using it as a depth value. imgThe depth value minus the minimum height of each point is stored in the image array ( ) by mapping the x and y coordinates to the row and column indices of the image.

Finally, the code maps the depth values ​​to the range of 0 to 255, saves the image array as an image file in PNG format ( test.png), and displays the depth image.

The function of converting three-dimensional point cloud data into a depth image is implemented. By projecting the point cloud onto the xoy plane and using the height difference as the depth value, the depth image is finally generated and saved as an image file in PNG format.

%将点云转换为深度图像
clear
close all;
clc

%获取点云数据
[fileName,pathName]=uigetfile('*.txt','Input Data-File');   %选择要进行计算的三维点云数据文件路径

if isempty(fileName) || length(fileName) == 1
    fprintf("未选择点云文件!\n");
    return;
end
Data=importdata([pathName,fileName]);   %加载点云数据
Data=Data(:,1:3);     %取数据的一到三列
Data(isnan(Data(:,3))==1,3) = 0;

x = Data(:,1);
y = Data(:

Guess you like

Origin blog.csdn.net/a394467238/article/details/132586429