Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add colour to point? #155

Closed
edent opened this issue Apr 3, 2018 · 2 comments
Closed

Add colour to point? #155

edent opened this issue Apr 3, 2018 · 2 comments

Comments

@edent
Copy link

edent commented Apr 3, 2018

Is it possible to change the colours of individual points in a pointcloud? For example, having a different RGB value assigned to specific points.

Thanks for the library, BTW, has been very useful.

@daavoo
Copy link
Owner

daavoo commented Apr 4, 2018

If you know the index of the points that you want to change, you can assign RGB values to individual points as follows:

import numpy as np
from pyntcloud import PyntCloud

cloud = PyntCloud.from_file("tests/data/diamond.ply")

# Should show 4 red points, 1 blue, 1 green.
cloud.plot()

point_to_change = 0
new_rgb = np.array([255, 255, 255], dtype=np.uint8)

cloud.points.loc[point_to_change, ["red", "green", "blue"]] = new_rgb

# Should show 3 red points, 1 blue, 1 green and 1 white.
cloud.plot()

Is that what you meant?

@edent
Copy link
Author

edent commented Apr 4, 2018

That's perfect! For anyone else searching for the error KeyError: "['red' 'green' 'blue'] not in index", I fixed this by starting with a DataFrame like:

`df = pd.DataFrame(np.random.uniform(0.1,1.0, size=(1024, 6)),columns=['x', 'y', 'z',"red","green","blue"])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants