How to Visualize Normal Vectors on 3D Point Clouds

This post will show you a good way to visualize normal vectors on 3D point clouds.

At the beginning of my master’s degree, I was working on a project where I used normal vectors on 3D point clouds to perform 3D point cloud over-segmentation.

One of the first things I did was to try and visualize the normal vectors and the point clouds. As a mechanical engineer, my first go-to programming language for such tasks is MATLAB, so I was happy to see that it has a nice function for plotting vectors:


Here x,y,z are the point coordinates and u,v,w are the vector components.

The problem

The problem was that for complex 3D point clouds (like from the NYU Depth V2 dataset) this visualization is not very informative (it is very hard to see where the little arrows are pointing).

3D point clouds with normal vectors  visualization as arrows
Normal vector visualization using quiver3 of a scene from NYU Depth V2

The solution

Therefore, I created a nice function that maps a vector to the RGB cube:

[RGB] = Sphere2RGBCube(V)

It is available for download on MATLAB file exchange, here. It also includes a short demo and an even more comprehensive demonstration of how the color mapping is performed.

For the comprehensive demonstration simply run


And you will get the following interface :

Normal Vector color mapping comprehensive demonstration

In the top left, you can see the RGB cube. At the bottom left, you can see the unit sphere with the mapped colors. Both include a small red dot which you can move using the arrow keys. To the right, you can see the color and its corresponding RGB values of the red dot. This illustrates what the mapping function does – it takes a unit vector (a point on the sphere), finds where it intersects the RGB cube, and uses that color as the vector representation.

Note that there are actually two mapping functions:

[RGB] = Sphere2RGBCube(V)
[RGB] = Sphere2RGBCube_accurate(V)

The main difference between the two is that the “accurate” version generates RGB colors on the cube planes. When plotting a sphere, for example, it is evident that the color mapping is not as smooth as one may want. Therefore, the “non-accurate” version creates a smoother color mapping (basically a sphere encapsulated within the RGB cube).

Finally, here is an example of the same point cloud as before, but this time with color mapping:

3D point clouds with normal vectors color mapped visualization
Normal vector visualization using RGB mapping of a scene from NYU Depth V2

This code was used in our recent paper on normal estimation for 3D point clouds. If you find this post and code useful, please cite it 🙂