UNPKG

@playcanvas/splat-transform

Version:

Library and CLI tool for 3D Gaussian splat format conversion and transformation

36 lines (35 loc) 1.64 kB
import { DataTable } from '../data-table/data-table'; /** * Optimal 1D quantization using dynamic programming on a histogram. * * Pools all columns of the input DataTable into a single 1D dataset, * sorts the values, bins them using a blend of uniform and quantile * positioning, then uses DP to find k centroids that minimize weighted * sum-of-squared-errors (SSE). * * Bin positions are an adaptive blend of uniform (value-space) and * quantile (rank-space) positioning. The blend ratio is computed from * the data's IQR-to-range ratio: extreme outlier distributions (small * IQR relative to range) use near-pure quantile to give the dense * center adequate bins, while moderate-tail distributions reduce * quantile bias (but keep at least 50% quantile weighting). * * Bin weights use sub-linear density weighting: weight = count^alpha. * With alpha < 1, sparse tail regions earn meaningful influence on * centroid placement. * * @param dataTable - Input data table whose columns are pooled into 1D. * @param k - Number of codebook entries (default 256). * @param alpha - Density weight exponent. 0 = uniform (each bin equal), * 0.5 = sqrt (balanced), 1.0 = standard MSE (dense regions dominate). * Default 0.5. * @returns Object with `centroids` (DataTable with one 'data' column of * k Float32 values, sorted ascending) and `labels` (DataTable with same * column layout as input, each column containing Uint8Array indices into * the codebook). */ declare const quantize1d: (dataTable: DataTable, k?: number, alpha?: number) => { centroids: DataTable; labels: DataTable; }; export { quantize1d };