Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rubenwiersma/pointcloud-differential
Gradient, divergence, Laplacian on point clouds. Useful for setting up and solving PDEs on point clouds and learning anisotropic features in deep learning.
https://github.com/rubenwiersma/pointcloud-differential
Last synced: 2 months ago
JSON representation
Gradient, divergence, Laplacian on point clouds. Useful for setting up and solving PDEs on point clouds and learning anisotropic features in deep learning.
- Host: GitHub
- URL: https://github.com/rubenwiersma/pointcloud-differential
- Owner: rubenwiersma
- License: mit
- Created: 2022-08-15T07:46:59.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-08-20T10:14:43.000Z (over 2 years ago)
- Last Synced: 2023-03-08T23:35:52.854Z (almost 2 years ago)
- Language: Python
- Size: 1.97 MB
- Stars: 61
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `pcdiff`: Differential operators on point clouds
Simple and small library to compute differential operators (gradient, divergence, Laplacian) on point clouds.![Example gradient of x-coordinate](assets/img/gradient.png)
_Visualization in [Polyscope](https://polyscope.run) of the output of the gradient operator on the x-coordinate of Spot (by Keenan Crane)._
## Installation
The recommended installation method is by using pip:
```bash
pip install pcdiff
```## Example usage
See [examples/demo.py](examples/demo.py) for a full visual demo. For a quick start:
```python
import numpy as np
from pcdiff import knn_graph, estimate_basis, build_grad_div, laplacian# Random point cloud
pos = np.random.rand(1000, 3)# Generate kNN graph
edge_index = knn_graph(pos, 20)
# Estimate normals and local frames
basis = estimate_basis(pos, edge_index)
# Build gradient and divergence operators (Scipy sparse matrices)
grad, div = build_grad_div(pos, *basis, edge_index)# Setup the Laplacian as the divergence of gradient:
laplacian = -(div @ grad)# Define some function on the point cloud
x = np.random.rand(1000, 1)# Compute gradient of function
# The output is of size 2N, with the two components of the vector field interleaved:
# [x_1, y_1, x_2, y_2, ..., x_N, y_N]
grad_x = grad @ x
```For sake of simplicity, every operation is written in Numpy and could be accelerated with Numba or Jax. If you would like to use these operators in PyTorch, please refer the github repository for [DeltaConv](https://github.com/rubenwiersma/deltaconv). The operators are accessible from `deltaconv.geometry`.
## How does it work?
We use a moving-least-squares approach. TL;DR: we fit a small patch of surface to each point's neighborhood and compute gradient and divergence on this patch of surface. A more detailed procedure is described in [the paper where we used this technique](https://rubenwiersma.nl/assets/pdf/DeltaConv.pdf) and [its supplement](https://rubenwiersma.nl/assets/pdf/DeltaConv_supplement.pdf).The output of this procedure is a $2N \times N$ sparse matrix for gradient and $N \times 2N$ sparse matrix for divergence. We also add functionality to use these matrices to compute co-gradient, curl, and Laplacians on a scalar/vector field on point clouds. This functionality can be found in [pcdiff/operators.py](pcdiff/operators.py).
## Alternatives
There are many alternatives to compute discrete differential operators in Python (e.g., `potpourri3d`, `libigl`, `gptoolbox`). Most of them did not have an implementation available or exposed for gradients and divergence on point clouds. Do check out these awesome libraries; `pcdiff` is intended to complement them.## Citation
If you find this library useful in your own work, please cite our paper on DeltaConv, a convolution for point clouds that uses these operators:```bib
@Article{Wiersma2022DeltaConv,
author = {Ruben Wiersma, Ahmad Nasikun, Elmar Eisemann, Klaus Hildebrandt},
journal = {Transactions on Graphics},
title = {DeltaConv: Anisotropic Operators for Geometric Deep Learning on Point Clouds},
year = {2022},
month = jul,
number = {4},
volume = {41},
doi = {10.1145/3528223.3530166},
publisher = {ACM},
}
```