forked from younahjeon/apple_facestim_generation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLinRegressBeta.m
27 lines (20 loc) · 938 Bytes
/
LinRegressBeta.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function [beta] = LinRegressBeta(Y,X,ridgeweight)
%% Finding Linear Mapping between Mesh and BlendShapes
% Y = Xb
% Y is mesh vertices.
% size = number of Frames x number of Vertices (nf x 3660)
%
% X is blendshape coeffiecients for a specific mesh.
% size = number of Frames x number of BlendShapes (nf x 53)
% a dummy variable is needed, so X should have 1's at 53rd column.
%
% b is betas(weights), or how much each blendshape coefficient influences a
% specific vertex. Each row represents how much a single blendshape
% coefficient distorts a mesh
% size = number of BlendShapes x number of Verties (53 x 3660)
% ridgeweight determines the strength of L2 norm. Ridge regression solves
% the multicollinearity problem which arises when independent variables are
% actually near-linearly related. With enough samples (number of frames), you can
% avoid this problem.
beta = pinv(X'*X+ ridgeweight*eye(size(X,2)))*X'*Y;
end