torch-points3d / torch-points-kernels

Pytorch kernels for spatial operations on point clouds
MIT License
96 stars 25 forks source link

Useful for interpolating unstructured data onto a grid? #59

Closed thomasaarholt closed 2 years ago

thomasaarholt commented 3 years ago

Hiya,

I'm searching for a GPU implementation of something like scipy's griddata - in order to interpolate points from an unstructured point cloud. My data is technically 2D, but I'm imagining just appending a z=0 coordinate to each point.

griddata above does the following. Can this library do something similar?

import numpy as np
from scipy.interpolate import LinearNDInterpolator
from scipy.spatial import Delaunay

N = 10000 # number of points
known_points = np.random.random((N,2))
known_intensities = np.random.random((N,))
tesselated_grid = Delaunay(known_points) # create a triangulated grid out of the known points
func = LinearNDInterpolator(tesselated_grid , known_intensities , fill_value=np.nan) # create an interpolation function
func((0.5, 0.3)) # What is the interpolated value at (0.5, 0.3)?
nicolas-chaulet commented 3 years ago

Hey! Thanks for the interest and the short answer is not really... We support interpolation from a fixed grid to another one using the three closest points: https://github.com/nicolas-chaulet/torch-points-kernels/blob/88dfbd542b1c4275012025c4b3708711ec0ce904/torch_points_kernels/torchpoints.py#L109 and https://github.com/nicolas-chaulet/torch-points-kernels/blob/88dfbd542b1c4275012025c4b3708711ec0ce904/torch_points_kernels/torchpoints.py#L40

But not the generic function kind of interpolation.

thomasaarholt commented 3 years ago

Thanks! Your package really did catch my eye! There are very few repos out there that do interpolation on the GPU, much less that do so on a point cloud!

If the package were at some point to include it, for instance as a function of some input Delaunay simplices/vertices grid, then I would really appreciate it if you dropped a message on this issue! I'm currently interpolating 10**7 points multiple times, and it's taking a little while :)

CCInc commented 2 years ago

Unfortunately this is not planned at the moment, but feel free to contribute it if you want!