heremaps / pptk

The Point Processing Toolkit (pptk) is a Python package for visualizing and processing 2-d/3-d point clouds.
https://heremaps.github.io/pptk
MIT License
610 stars 112 forks source link

How do I set the point color with different labels? #41

Open LeanderWayne opened 4 years ago

LeanderWayne commented 4 years ago

Hi, I have point cloud data with ground truth labels, but how do I set the point with different colors like the partition result shown in 'Visualizing the Semantic3D dataset' tutorial?

tddaniel commented 4 years ago

Maybe something like this? Make data array, each point has (x,y,z,label) with the labels randomly chosen from 0-3

import pptk
import numpy as np

x = np.random.randn(4000,4)
labels = [0,1,2,3]
for i, _ in enumerate(x):
    x[i,-1] = np.random.choice(labels)

Make the viewer passing in the (x,y,z) values as the first argument and just the labels as the second. I just changed the point size and initial r to better defaults for this data.

v = pptk.viewer(x[:,:-1],x[:,-1])
v.set(point_size=0.1)
v.set(r=20)

you could also make an RGBA array with one color for each point with the colors corresponding to the labels.