Lagrange
Loading...
Searching...
No Matches
texture_compositing.h
1/*
2 * Copyright 2025 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include <lagrange/SurfaceMesh.h>
15#include <lagrange/image/Array3D.h>
16#include <lagrange/image/View3D.h>
17
18#include <optional>
19#include <string_view>
20#include <utility>
21
22namespace lagrange::texproc {
23
26
43
48{
50 double value_weight = 1e3;
51
53 unsigned int quadrature_samples = 6;
54
56 double jitter_epsilon = 1e-4;
57
59 std::optional<std::pair<double, double>> clamp_to_range = std::nullopt;
60
63
67 bool use_direct_solver = false;
68
73
78
81 std::optional<bool> sanity_check = std::nullopt;
82
85 {
87 unsigned int num_multigrid_levels = 4;
88
91
93 unsigned int num_v_cycles = 4;
94 } solver;
95};
96
100template <typename ValueType>
102{
104 image::experimental::View3D<const ValueType> texture;
105
108 image::experimental::View3D<const float> weights;
109};
110
124template <typename Scalar, typename Index, typename ValueType>
125image::experimental::Array3D<ValueType> texture_compositing(
126 const SurfaceMesh<Scalar, Index>& mesh,
127 std::vector<ConstWeightedTextureView<ValueType>> textures,
128 const CompositingOptions& options = {});
129
131
132} // namespace lagrange::texproc
A general purpose polygonal mesh class.
Definition SurfaceMesh.h:73
GradientNormalization
How per-view gradient contributions are normalized when assembling the edge-difference target.
Definition texture_compositing.h:30
image::experimental::Array3D< ValueType > texture_compositing(const SurfaceMesh< Scalar, Index > &mesh, std::vector< ConstWeightedTextureView< ValueType > > textures, const CompositingOptions &options={})
Composite multiple textures into a single texture.
Definition texture_compositing.cpp:457
@ PerTexelSqrt
Per-texel normalization with geometric-mean combination (legacy behavior): edge_target = sum_i(grad_i...
Definition texture_compositing.h:41
@ PerEdge
Per-edge weighted average of per-view gradients: edge_target = sum_i(grad_i * w_i(n1) * w_i(n2)) / su...
Definition texture_compositing.h:35
Multigrid solver options (ignored when use_direct_solver is true).
Definition texture_compositing.h:85
unsigned int num_gauss_seidel_iterations
Number of Gauss-Seidel iterations per multigrid level.
Definition texture_compositing.h:90
unsigned int num_multigrid_levels
Number of multigrid levels.
Definition texture_compositing.h:87
unsigned int num_v_cycles
Number of V-cycles to perform.
Definition texture_compositing.h:93
Options for texture compositing.
Definition texture_compositing.h:48
std::optional< bool > sanity_check
Whether to run solver sanity checks.
Definition texture_compositing.h:81
bool use_direct_solver
Use a direct (LDLT) solver instead of the multigrid v-cycle.
Definition texture_compositing.h:67
double stiffness_regularization_weight
Weight for combinatorial Laplacian regularization added to the stiffness matrix.
Definition texture_compositing.h:72
std::optional< std::pair< double, double > > clamp_to_range
Clamp out-of-range texels to the given range (nullopt to disable).
Definition texture_compositing.h:59
double value_weight
The weight for fitting the values of the signal.
Definition texture_compositing.h:50
bool smooth_low_weight_areas
When using GradientNormalization::PerTexelSqrt, whether to smooth pixels with a low total weight (< 1...
Definition texture_compositing.h:77
GradientNormalization gradient_normalization
How per-view gradient contributions are normalized into the edge-difference target.
Definition texture_compositing.h:62
unsigned int quadrature_samples
The number of quadrature samples to use for integration (in {1, 3, 6, 12, 24, 32}).
Definition texture_compositing.h:53
double jitter_epsilon
Jitter amount per texel (0 to deactivate).
Definition texture_compositing.h:56
A view of a texture with weights associated with each texel.
Definition texture_compositing.h:102
image::experimental::View3D< const ValueType > texture
Texture data for a specific view.
Definition texture_compositing.h:104
image::experimental::View3D< const float > weights
Confidence weights for each texel.
Definition texture_compositing.h:108