MATLAB to Point Cloud Library

matpcl is pure MATLAB code that allows interfacing with the Point Cloud Library (PCL) tools

10.3K Downloads

Updated 14 Aug 2013

View License

matpcl is pure MATLAB code that allows interfacing with the Point Cloud Library (PCL) tools by reading and writing PCD format files. Being pure MATLAB avoids all kinds of headaches in trying to link PCL code into MEX files which involves various grief such as versions of compilers and support libraries such as boost.

There are only four user-level functions:

savepcd() writes a matrix as an optionally coloured point cloud in an ASCII PCD format file.

loadpcd() reads an optionally colored point cloud from a PCD format file (ASCII or binary) and returns a matrix.

pclviewer() writes a matrix to a temporary file and invokes the pcl_viewer app for visualization. This is much much faster for rotating a large point cloud than using a MATLAB 3D plot.

lscpd() shows the attributes of the PCD files in the current directory

Point clouds are considered to be either:

2-d matrices, with one column per point. The rows are X, Y, Z and for a colored point cloud X, Y, Z, R, G, B. (R,G,B) are in the range 0 to 1.

3-d matrices, with planes X, Y, Z and for a colored point cloud X, Y, Z, R, G, B. (R,G,B) are in the range 0 to 1.

Limitations (for now):

- No support for reading/writing normals

Cite As

Peter Corke (2023). MATLAB to Point Cloud Library (https://www.mathworks.com/matlabcentral/fileexchange/40382-matlab-to-point-cloud-library), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.5.0.0

Fixed bugs as per online comments. Bug in decompressing binary files fixed, as well as dimension transposition. savepcd() now has an option to save binary files.

1.4.0.0

I've added some code to handle binary_compressed format, but it's not fully tested. To read these files requires LZF decoding, and so I had to write MATLAB code to do that (included as lzfd.m).

1.3.0.0

Now support organized point clouds. In MATLAB these are treated as 3D matrices with planes for X, Y, Z, etc.

Incorporated patch by Will.

Added lspcd() function to show attributes of PCD files in current directory.

1.2.0.0

Removed references to function numcols() and replaced with the standard MATLAB function size(). Bad coding habit on my part...

1.1.0.0

added logo image

1.0.0.0