Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle 3D voxels efficiently?

I have a 3D point clouds with million of points. I want to store these points in 3D voxel space. The number of voxles along coordinate axis are more than 3000(x), 4000(y), 1500(z), for a total of 3000*4000*1500 voxels. I need to store in a voxel; maximum number of points, min height, max height and centorid. However, 90% of voxels are empty. So it takes lot of memory to store this. Actually, I want to search 26 neighbor voxels of each voxels in later. So What is the best way to store this data in voxel space and get access to this efficiently?

Creating a multidimensional array, is not the best solution, in term of performance...please any hint?

like image 334
user1286780 Avatar asked Mar 22 '12 19:03

user1286780


People also ask

What is a 3D voxel?

In 3D computer graphics, a voxel represents a value on a regular grid in three-dimensional space. As with pixels in a 2D bitmap, voxels themselves do not typically have their position (i.e. coordinates) explicitly encoded with their values.

Are voxels 3D pixels?

What Does Volume Pixel (Volume Pixel or Voxel) Mean? A volumetric pixel (volume pixel or voxel) is the three-dimensional (3D) equivalent of a pixel and the tiniest distinguishable element of a 3D object. It is a volume element that represents a specific grid value in 3D space.


2 Answers

Classical data structures for this kind of data are kd-Trees and octrees..

Also, you should definitely take a look at the spatial searching and sorting data structures implemented in CGAL.

like image 152
hc_ Avatar answered Sep 22 '22 21:09

hc_


If it's really "just" millions of points, far more than 90% of the voxels will empty. I'd try a hashed multimap (std::unordered_multimap in C++11) from voxel coordinates to points. That gives you O(1) lookup, like an array. It comes with quite a lot overhead though, but it's probably the best compromise.

The only thing you need for this to work is an equality comparison in the voxel class, and a template specialisation std::hash<voxel>. You won't get "maximum number of points" implemented in any automatical way, but is that really useful anyway?

like image 23
leftaroundabout Avatar answered Sep 26 '22 21:09

leftaroundabout