Skip to content

Instantly share code, notes, and snippets.

@joschuck
Last active September 17, 2020 13:10
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joschuck/19b26aab50e6f302602de6c32488069b to your computer and use it in GitHub Desktop.
Save joschuck/19b26aab50e6f302602de6c32488069b to your computer and use it in GitHub Desktop.
Smooth out a depth image or array from lidar measurements
from scipy import ndimage
from PIL import Image
[...]
lidar_image = np.array(Image.open(filename))
smooth_lidar_image = Image.fromarray(ndimage.filters.maximum_filter(lidar_image, (5,5)), mode='I')
@keishatsai
Copy link

Hi, I am wondering that how do you get the top image from velodyne point bin file.
Could you teach me how? Does it involve also known focal length and baseline?
Thank you

@keishatsai
Copy link

Hello, I have tried your code , but I got the following errors:
Do you have any idea what this might happen?
I named module Image from PIL as getVELOIMG
Traceback (most recent call last):
File "projectVelo_detail.py", line 238, in
smooth_lidar_image = getVELOIMG.fromarray(ndimage.filters.maximum_filter(lidar_image, (5,5)), mode='I')
File "/usr/lib/python2.7/dist-packages/scipy/ndimage/filters.py", line 970, in maximum_filter
cval, origin, 0)
File "/usr/lib/python2.7/dist-packages/scipy/ndimage/filters.py", line 903, in _min_or_max_filter
sizes = _ni_support._normalize_sequence(size, input.ndim)
File "/usr/lib/python2.7/dist-packages/scipy/ndimage/_ni_support.py", line 64, in _normalize_sequence
raise RuntimeError(err)
RuntimeError: sequence argument must have length equal to input rank

@oyhq0708
Copy link

same problem as keishatsai. Could you help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment