# 最小二乘网格( Least-squares Meshes) 选取结点组成子网格

最小二乘网格就是利用所谓软约束soft constraint，把已知的Vertex（ 控制点 Vh）的约束作为新的行I*V=Vh，添加到方程组L*V=0后面，对应的是最小二乘的regularization项。

clear all
close all
path = 'data\';
meanshape = meanface.shape;
meantex = meanface.tex;
numv = size(meanshape,1);

% conert to ids, each v has a symetry point
ids=[symid;fliplr(symid)];ids=unique(ids,'rows');
ids=sortrows(ids,1);ids = ids(:,2);

[L,W] = cal_mesh_laplacian(double(meanshape),facetri,'conformal');

%soft constaint
[~,idcon]=max(meanshape(:,3)); % tip of nose 8321

total_count = 400;
while(1)
ncont = length(idcon);
if(ncont>total_count)
break;
end
i=(1:ncont);
% large weight
wi = 32 ;
Lv = sparse(i,idcon,wi,ncont,numv);
Lhs = [L;Lv];

vh = sparse(double(meanshape(idcon,:)));
Rhs = [zeros(numv,3); wi*vh];
V = Lhs\Rhs;
V = full(V);
dv = (V-meanshape);
ds = dv(:,1).^2 + dv(:,2).^2 + dv(:,3).^2;
[dsm,idmin] = max(ds);
idnew = idmin;

idcon = [idcon;idnew];
if(length(idcon)==10 || length(idcon)==100  || length(idcon)==200)
% draw with trimesh here
% ...
end
end

idnew = idmin;

替换成：

idmin_sym = ids(idmin);
if( idmin == idmin_sym )
idnew = idmin;
else
idnew = [idmin;idmin_sym];
end

[1] Olga Sorkine and Daniel Cohen-Or.  Least-Squares Meshes

http://blog.sciencenet.cn/blog-465130-1136399.html

## 全部精选博文导读

GMT+8, 2019-10-23 11:39