本文整理汇总了C++中TexturePtr::GetVariance方法的典型用法代码示例。如果您正苦于以下问题:C++ TexturePtr::GetVariance方法的具体用法?C++ TexturePtr::GetVariance怎么用?C++ TexturePtr::GetVariance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TexturePtr
的用法示例。
在下文中一共展示了TexturePtr::GetVariance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FitRest
void Optimizer::FitRest(mat& alpha,
mat& beta,
mat& rho,
mat& lamda,
InputPtr input,
ModelPtr model,
MeshPtr mesh,
ShapePtr shape,
TexturePtr texture)
{
mat alpha_gradient = mat(PrincipalNum, 1, fill::zeros);
mat alpha_hessian_inv = mat(PrincipalNum, PrincipalNum, fill::zeros);
mat beta_gradient = mat(PrincipalNum, 1, fill::zeros);
mat beta_hessian_inv = mat(PrincipalNum, PrincipalNum, fill::zeros);
Rho rho_para(rho, input, model, mesh, shape, texture);
Lamda lamda_para(lamda, model, mesh, shape, texture);
// 2500 1000 700 500 300 200
model->InitialRandomGenerator(ModelImage::REST);
double weight = 1.0 / 200;
for (int l = 0; l < 1000; ++l)
{
Alpha alpha_para(alpha, input, model, mesh, shape, texture);
Beta beta_para(beta, model, mesh, shape, texture);
// Generate random points
GenerateRandomPoints(model, GradientRandomNum);
double function_value = 0;
for (int i = 0; i < PrincipalNum; ++i)
{
double variance = shape->GetVariance(i);
alpha_gradient[i] = weight * ComputeIntensityGradient(input, &alpha_para, i) + 2 * alpha[i] / variance;
}
for (int i = 0; i < PrincipalNum; ++i)
{
double variance = texture->GetVariance(i);
beta_gradient[i] = weight * ComputeIntensityGradient(input, &beta_para, i) + 2 * beta[i] / variance;
}
alpha -= alpha_para.Step*alpha_gradient;
beta -= beta_para.Step*beta_gradient;
}
}
示例2: FitAll
void Optimizer::FitAll(mat& alpha,
mat& beta,
mat& rho,
mat& lamda,
InputPtr input,
ModelPtr model,
MeshPtr mesh,
ShapePtr shape,
TexturePtr texture)
{
mat alpha_gradient = mat(PrincipalNum, 1, fill::zeros);
mat alpha_hessian_inv = mat(PrincipalNum, PrincipalNum, fill::zeros);
mat beta_gradient = mat(PrincipalNum, 1, fill::zeros);
mat beta_hessian_inv = mat(PrincipalNum, PrincipalNum, fill::zeros);
mat rho_gradient = mat(RhoNum, 1, fill::zeros);
mat rho_hessian_inv = mat(RhoNum, RhoNum, fill::zeros);
mat lamda_gradient = mat(LamdaNum, 1, fill::zeros);
mat lamda_hessian_inv = mat(LamdaNum, LamdaNum, fill::zeros);
vec step(RhoNum, 1);
step.rows(0, 2).fill(0.00000006);
step.rows(3, 5).fill(0.0002);
step.rows(6, 6).fill(2.0);
mat step_mat = diagmat(step);
SetStartingValue(rho, lamda);
// 2500 1000 700 500 300 200
array<double, 6> weight_intensity = { { 1.0 / 1000, 1.0 / 900, 1.0 / 800, 1.0 / 700, 1.0 / 500, 1.0 / 300 } };
array<int, 6> para_num = { { 10, 15, 25, 35, 55, 99 } }; // 20 40
array<int, 6> iterations = { { 1000, 1000, 1000, 1000, 1000, 1000 } };
//array<double, 4> weight_intensity = { { 1.0 / 900, 1.0 / 700, 1.0 / 500, 1.0 / 400 } };
//array<int, 4> para_num = { { 10, 20, 40, 99 } }; // 20 40
//array<int, 4> iterations = { { 1000, 1000, 800, 600 } };
int counter = 0;
for (int c = 0; c < 6; ++c)
{
for (int l = 0; l < iterations[c]; ++l)
{
if (counter == 0 || counter % 1000 == 0)
{
Face3dModel face3d_model(shape, texture);
mesh = face3d_model.Construction(alpha, beta);
TwoPassZbuffer(rho, lamda, mesh, model);
model->EnableIterator();
model->InitialRandomGenerator();
//GenerateRandomPoints(model, HessianRandomNum);
//for (int i = 0; i < para_num[c]; ++i)
//{
// double variance = shape->GetVariance(i);
// mat alpha1 = alpha;
// alpha1[i] -= H;
// Alpha alpha_para1(alpha1, input, model, mesh, shape, texture);
// double first_derivative1 = weight_feature[c] * ComputeLandmarkGradient(input, &alpha_para1, i) +
// weight_intensity[c] * ComputeIntensityGradient(input, &alpha_para1, i);
// mat alpha2 = alpha;
// alpha2[i] += H;
// Alpha alpha_para2(alpha2, input, model, mesh, shape, texture);
// double first_derivative2 = weight_feature[c] * ComputeLandmarkGradient(input, &alpha_para2, i) +
// weight_intensity[c] * ComputeIntensityGradient(input, &alpha_para2, i);
// double second_derivative = (first_derivative2 - first_derivative1) / (2 * H);
// alpha_hessian_inv(i, i) = 1 / (second_derivative +2 / variance);
//}
/* for (int i = 0; i < para_num[c]; ++i)
{
double variance = texture->GetVariance(i);
mat beta1 = beta;
beta1[i] -= H;
Beta beta_para1(beta1, model, mesh, shape, texture);
double first_derivative1 = weight_intensity[c] * ComputeIntensityGradient(input, &beta_para1, i);
mat beta2 = beta;
beta2[i] += H;
Beta beta_para2(beta2, model, mesh, shape, texture);
double first_derivative2 = weight_intensity[c] * ComputeIntensityGradient(input, &beta_para2, i);
double second_derivative = (first_derivative2 - first_derivative1) / (2 * H);
beta_hessian_inv(i, i) = 1 / (second_derivative + 2 / variance);
//.........这里部分代码省略.........