malei-pku / ifp-sample

Cython iterative farthest point sampling implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Approximate Iterative Farthest Point Sampling

Cython implementation based on pre-computed distances (e.g. from a KDTree) using a priority queue.

Installation

pip install Cython
pip install git+git://github.com/jackd/ifp-sample.git

Or if you want to make changes:

git clone https://github.com/jackd/ifp-sample.git
pip install -e ifp-sample

Usage

import numpy as np
from scipy.spatial import cKDTree
from ifp import ifp_sample

coords = np.random.uniform(size=(1024, 3))
dists, indices = cKDTree(coords).query(coords, 8)
sampled_indices = ifp_sample(dists, indices, num_out=512)
sampled_coords = coords[sampled_indices]

See example.py for basic benchmark (~3x faster than pure python version).

About

Cython iterative farthest point sampling implementation


Languages

Language:Python 100.0%