MCPcopy
hub / github.com/PiLiDAR/PiLiDAR / colormap_pcd

Function colormap_pcd

lib/pointcloud.py:237–245  ·  view source on GitHub ↗
(pcd, cmap="viridis", gamma=2.2)

Source from the content-addressed store, hash-verified

235
236# colorize pointcloud using matplotlib colormap
237def colormap_pcd(pcd, cmap="viridis", gamma=2.2):
238 r = np.asarray(pcd.colors)[:, 0]
239 r_norm = (r - r.min()) / (r.max() - r.min())
240 r_corrected = r_norm**(gamma)
241 colors = matplotlib.colormaps[cmap](r_corrected) # Map the normalized color channel to the color map
242 if colors.shape[1] == 4:
243 colors = colors[:, :3] # Remove the alpha channel if present
244 pcd.colors = o3d.utility.Vector3dVector(colors)
245 return pcd
246
247# load point cloud from file (3D: pcd, ply, e57 | 2D: csv, npy), return as pcd object or numpy table
248# columns parameter: "XYZ" for 3D, "XZ" for 2D vertical, "I" for intensity or "RGB" for color

Callers 1

postprocess_3DFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected