Skip to contents

Filters out noisy, floating tie-points and airborne outliers from point clouds or Gaussian Splats based on local neighborhood density using a high-performance native C++ 3D Kd-Tree (OpenMP accelerated, zero external package dependencies).

Two filters are available (method):

  • "density" (default): the same voxel-grid density filter used by the Online Noise Filter panel of gs_viewer(). Space is divided into cubic voxels (cell_size, by default 1.2% of the robust subject size, clamped to 0.008-0.035 scene units), the density of each point is the number of points in the 3 x 3 x 3 voxel block around it, and the points whose density falls below the density percentile are removed. Because the cut-off is a percentile, it is not affected by a few extremely distant points, which is what makes the classical SOR filter too permissive on SfM clouds. The presets "light", "medium" and "strong" correspond to the viewer buttons (15, 35 and 65%).

  • "sor": Statistical Outlier Removal (mean distance to the k nearest neighbours, cut-off mean + std_ratio * sd), optionally combined with the radius filter (radius, min_neighbors).

  • "both": a point must pass both filters.

Usage

gs_filter_outliers(
  splat,
  k = 20,
  std_ratio = 1,
  radius = 0,
  min_neighbors = 0,
  verbose = TRUE,
  method = c("density", "sor", "both"),
  density = "medium",
  cell_size = NULL
)

Arguments

splat

A gaussian_splat, colmap_sfm, or numeric matrix of 3D coordinates.

k

Integer. Number of nearest neighbors to evaluate (e.g. 16 to 30). Defaults to 20. Used by method = "sor" / "both".

std_ratio

Numeric. Standard deviation multiplier threshold. Smaller values (e.g. 0.8 to 1.2) filter more aggressively, removing scattered floating points around the subject. Defaults to 1.0. Used by method = "sor" / "both".

radius

Numeric. Optional sphere radius for density filtering. If > 0, points with fewer than min_neighbors within radius are additionally filtered out. Defaults to 0.0 (disabled).

min_neighbors

Integer. Minimum neighbors required within radius. Defaults to 0 (disabled).

verbose

Logical. Show progress and statistics. Defaults to TRUE.

method

Character. "density" (default, same filter as gs_viewer()), "sor" or "both". See Description.

density

Filter strength for method = "density": a percentile between 0 and 100 (points below it are removed) or one of the viewer presets "light" (15), "medium" (35, default) or "strong" (65).

cell_size

Numeric. Voxel edge length (scene units) for method = "density". NULL (default) uses the same automatic rule as gs_viewer().

Value

An updated and cleaned gaussian_splat, colmap_sfm, or point matrix. The attribute "densities" holds the voxel density of the kept points (density filter) and "density_dists" the mean k-NN distance (SOR filter).

Examples

if (FALSE) { # interactive()
library(pliman)

# Clean floating noise from a COLMAP reconstruction (same as the viewer's
# "Medium" noise filter)
sfm_clean <- gs_filter_outliers(sfm_completo, density = "medium")

# Classical statistical outlier removal
sfm_sor <- gs_filter_outliers(sfm_completo, k = 20, std_ratio = 1.0, method = "sor")
plot(sfm_clean)
}