lagrange.texproc

Module Contents

Functions

geodesic_dilation(mesh, image[, dilation_radius])

Extend pixels of a texture beyond the defined UV mesh by walking along the 3D surface.

geodesic_position(mesh, width, height[, dilation_radius])

Computes a dilated position map to extend a texture beyond the defined UV mesh by walking along the 3D surface.

rasterize_textures_from_renders(scene, renders[, ...])

Rasterize one (color, weight) per (render, camera) and filter our low-confidence weights.

texture_compositing(mesh, colors, weights[, ...])

Composite multiple (color, weight) into a single texture given a unwrapped mesh.

texture_filtering(mesh, image[, value_weight, ...])

"Smooth or sharpen a texture image associated with a mesh.

texture_stitching(mesh, image[, exterior_only, ...])

Smooth or sharpen a texture image associated with a mesh.

lagrange.texproc.geodesic_dilation(mesh, image, dilation_radius=10)

Extend pixels of a texture beyond the defined UV mesh by walking along the 3D surface.

Parameters:
  • mesh (lagrange.core.SurfaceMesh) – Input mesh with UV attributes.

  • image (Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=(None, None, None), order='C', device='cpu')]) – Texture to extend beyond UV mesh boundaries.

  • dilation_radius (float) – The radius by which the texture should be dilated into the gutter.

Returns:

The dilated texture image.

Return type:

object

lagrange.texproc.geodesic_position(mesh, width, height, dilation_radius=10)

Computes a dilated position map to extend a texture beyond the defined UV mesh by walking along the 3D surface.

Parameters:
  • mesh (lagrange.core.SurfaceMesh) – Input mesh with UV attributes.

  • width (int) – Width of the output position map.

  • height (int) – Height of the output position map.

  • dilation_radius (float) – The radius by which the texture should be dilated into the gutter.

Returns:

The dilated position map.

Return type:

object

lagrange.texproc.rasterize_textures_from_renders(scene, renders, width=None, height=None, low_confidence_ratio=0.75, base_confidence=None)

Rasterize one (color, weight) per (render, camera) and filter our low-confidence weights.

Parameters:
  • scene (lagrange.scene.Scene) – Scene containing a single mesh (possibly with a base texture), and multiple cameras.

  • renders (collections.abc.Sequence[Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=(None, None, None), order='C', device='cpu')]]) – List of rendered images, one per camera.

  • width (int | None) – Width of the rasterized textures. Must match the width of the base texture if present. Otherwise, defaults to 1024.

  • height (int | None) – Height of the rasterized textures. Must match the height of the base texture if present. Otherwise, defaults to 1024.

  • low_confidence_ratio (float) – Discard low confidence texels whose weights are < ratio * max_weight.

  • base_confidence (float | None) – Confidence value for the base texture if present in the scene. If set to 0, ignore the base texture of the mesh. Defaults to 0.3 otherwise.

Returns:

A pair of lists (textures, weights), one per camera.

Return type:

tuple[list[object], list[object]]

lagrange.texproc.texture_compositing(mesh, colors, weights, value_weight=1000.0, quadrature_samples=6, jitter_epsilon=0.0001, smooth_low_weight_areas=False, num_multigrid_levels=4, num_gauss_seidel_iterations=3, num_v_cycles=5)

Composite multiple (color, weight) into a single texture given a unwrapped mesh.

Parameters:
  • mesh (lagrange.core.SurfaceMesh) – Input mesh with UV attributes.

  • colors (collections.abc.Sequence[Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=(None, None, None), order='C', device='cpu')]]) – List of texture images to composite. Input textures must have the same dimensions.

  • weights (collections.abc.Sequence[Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=(None, None, None), order='C', device='cpu')]]) – List of confidence weights for each texel. 0 means the texel should be ignored, 1 means the texel should be fully trusted. Input weights must have the same dimensions as colors.

  • value_weight (float) – The weight for fitting the values of the signal.

  • quadrature_samples (int) – The number of quadrature samples to use for integration (in {1, 3, 6, 12, 24, 32}).

  • jitter_epsilon (float) – Jitter amount per texel (0 to deactivate).

  • smooth_low_weight_areas (bool) – Whether to smooth pixels with a low total weight (< 1). When enabled, this will not dampen the gradient terms for pixels with a low total weight, resulting in a smoother texture in low-confidence areas.

  • num_multigrid_levels (int) – Number of multigrid levels.

  • num_gauss_seidel_iterations (int) – Number of Gauss-Seidel iterations per multigrid level.

  • num_v_cycles (int) – Number of V-cycles to perform.

Returns:

The composited texture image.

Return type:

object

lagrange.texproc.texture_filtering(mesh, image, value_weight=1000.0, gradient_weight=1.0, gradient_scale=1.0, quadrature_samples=6, jitter_epsilon=0.0001)

“Smooth or sharpen a texture image associated with a mesh.

Parameters:
  • mesh (lagrange.core.SurfaceMesh) – Input mesh with UV attributes.

  • image (Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=(None, None, None), order='C', device='cpu')]) – Texture image to filter.

  • value_weight (float) – The weight for fitting the values of the signal.

  • gradient_weight (float) – The weight for fitting the modulated gradients of the signal.

  • gradient_scale (float) – The gradient modulation weight. Use a value of 0 for smoothing, and use a value between [2, 10] for sharpening.

  • quadrature_samples (int) – The number of quadrature samples to use for integration (in {1, 3, 6, 12, 24, 32}).

  • jitter_epsilon (float) – Jitter amount per texel (0 to deactivate).

Returns:

The filtered texture image.

Return type:

object

lagrange.texproc.texture_stitching(mesh, image, exterior_only=False, quadrature_samples=6, jitter_epsilon=0.0001)

Smooth or sharpen a texture image associated with a mesh.

Parameters:
  • mesh (lagrange.core.SurfaceMesh) – Input mesh with UV attributes.

  • image (Annotated[numpy.typing.NDArray[numpy.float32], dict(shape=(None, None, None), order='C', device='cpu')]) – Texture image to stitch.

  • exterior_only (bool) – If true, interior texels are fixed degrees of freedom.

  • quadrature_samples (int) – The number of quadrature samples to use for integration (in {1, 3, 6, 12, 24, 32}).

  • jitter_epsilon (float) – Jitter amount per texel (0 to deactivate).

Returns:

The stitched texture image.

Return type:

object