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

The color of visualization for depth map #3

Closed
ccc870206 opened this issue Nov 2, 2021 · 3 comments
Closed

The color of visualization for depth map #3

ccc870206 opened this issue Nov 2, 2021 · 3 comments

Comments

@ccc870206
Copy link

Hi,
In your paper, I guess that your visualization for depth map uses cmap 'magma'.
I use the same cmap but get the following result.
0_pred

It looks more bright and yellow. I'm not sure if I make mistake.
Therefore, could you tell how you visualize the depth map or provide the code?
Many thanks.

@alopezgit
Copy link
Owner

Hi,

The function I used should be a modification of the following one. Try to play with the np.percentile parameters to see if you can make it look like you want to, as it limits the output colormap to a range of depth (or disparity in this code) values.

import PIL.Image as pil
import numpy as np
import matplotlib as mpl
import matplotlib.cm as cm
def convert_array_to_pil(depth_map):
    # Input: depth_map -> HxW numpy array with depth values 
    # Output: colormapped_im -> HxW numpy array with colorcoded depth values
    mask = depth_map!=0
    disp_map = 1/depth_map
    vmax = np.percentile(disp_map[mask], 95)
    vmin = np.percentile(disp_map[mask], 5)
    normalizer = mpl.colors.Normalize(vmin=vmin, vmax=vmax)
    mapper = cm.ScalarMappable(norm=normalizer, cmap='magma')
    mask = np.repeat(np.expand_dims(mask,-1), 3, -1)
    colormapped_im = (mapper.to_rgba(disp_map)[:, :, :3] * 255).astype(np.uint8)
    colormapped_im[~mask] = 255
    return colormapped_im

@alopezgit
Copy link
Owner

alopezgit commented Nov 7, 2021

I'm closing the issue for now, feel free to open another one if it is still not solved.

@ccc870206
Copy link
Author

It's really helpful! Thank you!

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