yotamnahum / farthest-point-sampling

Farthest Point Sampling Made Easy: A Python library leveraging NumPy for fast and resource-friendly selection of farthest points in large multidimensional datasets.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Farthest Point Sampling

Efficient Farthest Point Sampling: A performant Python implementation for subsampling large point clouds without exhaustive distance calculations. This lightweight library is optimized for performance and ease-of-use in large datasets, leveraging the power of NumPy.

Farthest Point Sampling Example

Example of Farthest Point Sampling (image source: Minibatch AI Blog)

Table of Contents

Introduction

Farthest Point Sampling (FPS) is a widely used technique in computer graphics, machine learning, and computational geometry to reduce the size of a point cloud while preserving the overall structure. This Python implementation provides a fast and efficient way to perform FPS on large datasets without the need to compute all pairs of distances.

Installation

To use this library, simply clone the repository to your local machine using the following command:

bashCopy code

git clone https://github.com/yotamnahum/farthest-point-sampling.git

Once the repository is cloned, you can import the farthest_point_sampling function from the main file in your Python scripts or Jupyter notebooks.

from farthest_point_sampling import farthest_point_sampling

Usage Examples

Here are some examples demonstrating how to use the farthest_point_sampling function:

### Basic Usage
import numpy as np
from farthest_point_sampling import farthest_point_sampling

data = np.random.rand(100, 1024)
point_idx = farthest_point_sampling(data, 3) 
print(point_idx)
# Output: array([80, 79, 27])
### Specifying a Starting Point
import numpy as np
from farthest_point_sampling import farthest_point_sampling

data = np.random.rand(100, 1024)
point_idx = farthest_point_sampling(data, 5, start_idx=60)
print(point_idx)
# Output: array([60, 39, 59, 21, 73])`

Feel free to experiment with different datasets and tweak the parameters to achieve the desired level of point cloud reduction. This efficient implementation makes it easy to incorporate Farthest Point Sampling into your projects for improved performance and resource usage.

About

Farthest Point Sampling Made Easy: A Python library leveraging NumPy for fast and resource-friendly selection of farthest points in large multidimensional datasets.

License:MIT License


Languages

Language:Python 100.0%