I have a 3D data matrix which contains information about a scene (which voxels are free / occupied and belong to which class).
So far to plot the data I have to plot 2D slices using imagesc
.
I'd like to plot the data as a pointcloud using Matlabs pcshow
which should only display occupied voxels and the display the rest as empty space.
How can I convert my 3D matrix into a pointcloud object?
For some NxMxK matrix A
where A == 255
indicates free voxels:
% 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))