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

Q: How to set min/max for colormap when rendering a pointcloud? #2545

Closed
maxfreu opened this issue Oct 26, 2020 · 3 comments
Closed

Q: How to set min/max for colormap when rendering a pointcloud? #2545

maxfreu opened this issue Oct 26, 2020 · 3 comments
Labels
documentation Documentation improvements visualization

Comments

@maxfreu
Copy link

maxfreu commented Oct 26, 2020

Hi! I would like to set the range of the colormap when rendering a pointcloud; I only want a color gradient from e.g. z=0 to z=1 although there are points above and below that region. Is this currently possible? If yes, how?
Edit: I am using v0.9.0 btw

@germanros1987
Copy link
Contributor

This is possible using the new API. @errissa could you please provide an example?

@ssheorey
Copy link
Member

ssheorey commented Dec 6, 2021

Hi @maxfreu please upgrade to the latest Open3D v0.14.1. Here is sample code for using the color gradient with the new API:

import open3d as o3d
from open3d.core import Tensor, concatenate
from open3d.visualization import rendering, draw
from open3d.ml.vis import Colormap

# Create a helix point cloud. We will use the Z values to assign colors.
values = Tensor.arange(start=0.0, stop=1.0, step=0.001,
                       dtype=o3d.core.float32).reshape((-1, 1))
period = 0.2
xyz = concatenate(
    ((6.28 / period * values).sin(), (6.28 / period * values).cos(), values), 1)
pcd = o3d.t.geometry.PointCloud(xyz)
# Use a special point property to specify colormap lookup values for the point
# cloud.
pcd.point['__visualization_scalar'] = values
# Use a default rainbow colormap
colormap = Colormap.make_rainbow()
# Add alpha channel and convert to Gradient Points
colormap = list(
    rendering.Gradient.Point(pt.value, pt.color + [1.0])
    for pt in colormap.points)
# Now create the material
material = rendering.MaterialRecord()
material.shader = "unlitGradient"
material.gradient = rendering.Gradient(colormap)
material.gradient.mode = rendering.Gradient.GRADIENT
material.scalar_min = 0.0
material.scalar_max = 1.0

draw({
    'name': 'helix',
    'geometry': pcd,
    'material': material
},
     point_size=3,
     show_skybox=False)

Screenshot 2021-12-06 at 11 35 27 AM

@maxfreu
Copy link
Author

maxfreu commented Dec 7, 2021

Thanks! It will take a while until I come around to trying it out, but good to know it works now. I leave it at your descretion to close the issue.

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

No branches or pull requests

5 participants