Utility helpers¶
Utility functions for Gaussian Splatting operations.
- gsply.utils.sh2rgb(sh)[source]¶
Convert SH DC coefficients to RGB colors.
- Parameters:
- Return type:
- Returns:
RGB colors in [0, 1] range
Example
>>> import gsply >>> sh = np.array([[0.0, 0.5, -0.5]]) >>> rgb = gsply.sh2rgb(sh) >>> print(rgb) # [[0.5, 0.641, 0.359]]
- gsply.utils.rgb2sh(rgb)[source]¶
Convert RGB colors to SH DC coefficients.
- Parameters:
rgb (
ndarray|float) – RGB colors in [0, 1] range (N, 3) or scalar- Return type:
- Returns:
SH DC coefficients
Example
>>> import gsply >>> rgb = np.array([[1.0, 0.5, 0.0]]) >>> sh = gsply.rgb2sh(rgb)
- gsply.utils.sigmoid(x)[source]¶
Compute sigmoid function (inverse logit) with numerical stability.
Optimized for both scalar and array inputs using Numba. Formula: 1 / (1 + exp(-x))
- gsply.utils.logit(x, eps=1e-06)[source]¶
Compute logit function (inverse sigmoid) with numerical stability.
Optimized for both scalar and array inputs using Numba. Formula: log(x / (1 - x))
- gsply.utils.apply_pre_activations(data, *, min_scale=9.999999747378752e-05, max_scale=100.0, min_quat_norm=9.99999993922529e-09, inplace=True)[source]¶
Activate GSData attributes (scales, opacities, quaternions) in a single fused pass.
This function uses a fused Numba kernel that processes all three attributes together for optimal performance (~8-15x faster than individual operations).
- Parameters:
data (
GSData) – GSData instance to processmin_scale (
float) – Minimum allowed scale value after exponentiationmax_scale (
float) – Maximum allowed scale value after exponentiationmin_quat_norm (
float) – Norm floor for normalizing quaternions (avoids NaNs)inplace (
bool) – If False, returns a copy before activation
- Return type:
- Returns:
GSData with activated attributes (either modified in-place or copy)
Example
>>> import gsply >>> data = gsply.plyread("scene_logits.ply") >>> gsply.apply_pre_activations(data, inplace=True)
- gsply.utils.apply_pre_deactivations(data, *, min_scale=1e-09, min_opacity=0.0001, max_opacity=0.9999, inplace=True)[source]¶
Deactivate GSData attributes (scales, opacities) in a single fused pass.
This function uses a fused Numba kernel that processes scales and opacities together for optimal performance (~8-15x faster than individual operations).
- Parameters:
- Return type:
- Returns:
GSData with deactivated attributes (either modified in-place or copy)
Example
>>> import gsply >>> data = gsply.GSData(...) # Linear format >>> gsply.apply_pre_deactivations(data, inplace=True)