-1

I have a XYZRGB -formatted point cloud data. The file size is huge and it consists of hundreds of thousands of points. How can I decrease the density of points? Say for each 10 neighbors, I want to have a single point average of all other points (both XYZ and RGB). Any piece of code in Java or Matlab is welcome. Here is a sample .ply point cloud file you can work on: https://drive.google.com/open?id=0B667VfPLdu3_RVpKV1liZ0ktRVU

I was trying some interpolation in Matlab as below. But this is not what I want. I need to decrease density.

% Load Point Cloud:
Point_Cloud  = importdata(‘Point_Cloud_1.txt')
x            = Point_Cloud(1,:)';
y            = Point_Cloud(2,:)';
z            = Point_Cloud(3,:)';

% Interpolate inspection points:
Density = 300;
[X,Y]   = meshgrid(linspace(min(x), max(x), Density), linspace(min(y), max(y), Density));
F       = scatteredInterpolant(x, y, z, 'natural','linear');
Z       = F(X,Y);
Int_PC  = [reshape(X,Density^2,1) reshape(Y,Density^2,1) reshape(Z,Density^2,1)];
Int_PC(any(isnan(Int_PC{i}),2),:) = [];  

% Plot results:
scatter3(x, y, z, 20, 'r', 'fill'); % Original data
hold on;
scatter3(Int_PC(:,1), Int_PC(:,2), Int_PC(:,3), 20, 'r', 'fill'); % Interpolated data
Tina J
  • 4,983
  • 13
  • 59
  • 125

1 Answers1

0

The VoxelGrid filter will accomplish what you are looking for. This provides some explanation and sample code: http://pointclouds.org/documentation/tutorials/voxel_grid.php

brad
  • 930
  • 9
  • 22
  • Does it work with my provided sample file? It's XYZRGB .ply formatted. – Tina J Jun 16 '17 at 16:13
  • Yes once the point cloud is loaded. https://stackoverflow.com/questions/30764222/how-to-read-ply-file-using-pcl – brad Jun 16 '17 at 18:48