question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Showing RGBD images using graph_objects.Surface?

See original GitHub issue

Not an issue exactly, but I am trying to show RGBD images (with Depth) using surface and the ‘hack’ I found to do it now was to convert the image into 8-bit GIF, use the 8-bit index as the value, color the image by value and use the gif 8-bit palette as the colorscale. Is there an easier way, or should I make a tutorial in case someone else wants to do the same thing?

from PIL import Image
img_as_8bit = lambda x: np.array(Image.fromarray(x).convert('P', palette='WEB', dither=None))
dum_img = Image.fromarray(np.ones((3,3,3), dtype='uint8')).convert('P', palette='WEB')
idx_to_color = np.array(dum_img.getpalette()).reshape((-1, 3))
colorscale=[[i/255.0, "rgb({}, {}, {})".format(*rgb)] for i, rgb in enumerate(idx_to_color)]
trace=go.Surface(
           z=depth_image,
        surfacecolor=img_as_8bit(rgb_image),
        cmin=0, 
        cmax=255,
        colorscale=colorscale
          )
fig = go.Figure(
    data=[trace],
    layout_title_text="3D Face Mesh"
)
fig

image

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:7
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
kmadercommented, Nov 7, 2019

Here is a self-contained notebook using public data https://www.kaggle.com/kmader/show-rgb-d-image-in-3d-plotly

2reactions
bsridattacommented, Apr 16, 2020

Well, let me reel in my enthusiasm: the image trace type is 2-d not surface 😉 Still, this is pretty cool, and we can maybe imagine generalizing surface like this someday.

@nicolaskruchten So can we have 2D RGB in a 3D plot say, alongside a scatter plot like in the picture below? I couldn’t find a way to do so, I have tried the approach by kmader but looking for a better res image. Thanks

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Show RGB-D image in 3D Plotly
RGB Surface Code¶. Here is the code using PIL and the web palette to convert our images into nice plotly plots. In [ ......
Read more >
RGBD images — Open3D 0.12.0 documentation
The following tutorials show how to read and use RGBD images from a number of well known RGBD datasets. Redwood dataset¶. In this...
Read more >
plotly.graph_objects.Surface — 5.11.0 documentation
showlegend – Determines whether or not an item corresponding to this trace is shown in the legend. showscale – Determines whether or not...
Read more >
3D rendering of colored surfaces
http://newtec.univ-lille1.fr/Movies/3d/Bodele2-rgbd.html. Here the image, we are using in input, with an elevation model.
Read more >
Object Discovery with Metadata. (Top) Robotic agent ...
(Top) Robotic agent navigates through office environment storing an RGBD video ... (b) Images in the sequence are segmented to generate object candidates....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found