如何在Matlab中将3D数据矩阵保存为pointcloud?

时间:2017-07-23 17:28:44

标签: matlab point-clouds

我有一个3D数据矩阵,其中包含有关场景的信息(体素是空闲/占用的,属于哪个类)。

到目前为止,绘制我必须使用imagesc绘制2D切片的数据。

我想使用Matlabs pcshow将数据绘制为pointcloud,它只应显示占用的体素,并将其余部分显示为空白区域。

如何将3D矩阵转换为pointcloud对象?

1 个答案:

答案 0 :(得分:1)

对于某些NxMxK矩阵A,其中A == 255表示自由体素:

% make coordinate grid the size of A
[X,Y,Z] = meshgrid(1:size(A,1),1:size(A,2),1:size(A,3));
% move to xyz format
xyz=[X(:) Y(:) Z(:)];
% show points which are not free and where group values are used as color (scaled by to current colormap)
pcshow(xyz(A~=255,:),A(A~=255))