How is it possible to color a 3D shape /point cloud (in my case a human body), in such a way that each point has a different color but the color transition from point to point is smooth, as shown in the picture below?

The shape of N points is represented as an Nx3 array of point coordinates x,y,z. I tried to simply convert the coordinate values x,y,z of each point to r,g,b color values, but the result isn't satisfying (e.g. some points that are close to each other according to the Euclidean distance are colored by a similar color but they should be colored with different colors because their geodesic distance is large).
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
pc = ...
colors = (pc - pc.min()) / (pc.max() - pc.min())
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(pc[1], pc[1], pc[2], c=colors)
plt.show()
I found a way to do it which gives a satisfying result.
The idea is to color a sphere based on the coordinates of its vertices (as shown in the question). Such a coloring is nice because there are no problems with "Euclidean vs geodesic distance" as in human shapes.
Then, we can use Pytorch3D to deform the sphere to the input shape as described here. In this way the sphere coloring is smoothly transferred to the human shape. Although I have a point cloud with only vertex coordinates, the result is pretty good.
Below is an example of coloring a dolphin by using this method:

One problem is that we still need to transfer the coloring from the obtained shape to the original shape, something that perhaps could be done by finding nearest neighbors between the two (I haven't tried it though).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With