p=smoothsurf(node,mask,conn,iter,useralpha,usermethod,userbeta) smoothing a surface mesh author: Qianqian Fang, <q.fang at neu.edu> date: 2007/11/21 input: node: node coordinates of a surface mesh mask: flag whether a node is movable: 0 movable, 1 non-movable if mask=[], it assumes all nodes are movable conn: input, a cell structure of length size(node), conn{n} contains a list of all neighboring node ID for node n, this can be computed from meshconn function iter: smoothing iteration number useralpha: scaler, smoothing parameter, v(k+1)=(1-alpha)*v(k)+alpha*mean(neighbors) usermethod: smoothing method, including 'laplacian','laplacianhc' and 'lowpass' userbeta: scaler, smoothing parameter, for 'laplacianhc' output: p: output, the smoothed node coordinates recommendations Based on [Bade2006], 'Lowpass' method outperforms 'Laplacian-HC' in volume preserving and both are significantly better than the standard Laplacian method [Bade2006] R. Bade, H. Haase, B. Preim, "Comparison of Fundamental Mesh Smoothing Algorithms for Medical Surface Models," Simulation and Visualization, pp. 289-304, 2006. -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0001 function p=smoothsurf(node,mask,conn,iter,useralpha,usermethod,userbeta) 0002 % 0003 % p=smoothsurf(node,mask,conn,iter,useralpha,usermethod,userbeta) 0004 % 0005 % smoothing a surface mesh 0006 % 0007 % author: Qianqian Fang, <q.fang at neu.edu> 0008 % date: 2007/11/21 0009 % 0010 % input: 0011 % node: node coordinates of a surface mesh 0012 % mask: flag whether a node is movable: 0 movable, 1 non-movable 0013 % if mask=[], it assumes all nodes are movable 0014 % conn: input, a cell structure of length size(node), conn{n} 0015 % contains a list of all neighboring node ID for node n, 0016 % this can be computed from meshconn function 0017 % iter: smoothing iteration number 0018 % useralpha: scaler, smoothing parameter, v(k+1)=(1-alpha)*v(k)+alpha*mean(neighbors) 0019 % usermethod: smoothing method, including 'laplacian','laplacianhc' and 'lowpass' 0020 % userbeta: scaler, smoothing parameter, for 'laplacianhc' 0021 % 0022 % output: 0023 % p: output, the smoothed node coordinates 0024 % 0025 % recommendations 0026 % Based on [Bade2006], 'Lowpass' method outperforms 'Laplacian-HC' in volume 0027 % preserving and both are significantly better than the standard Laplacian method 0028 % 0029 % [Bade2006] R. Bade, H. Haase, B. Preim, "Comparison of Fundamental Mesh 0030 % Smoothing Algorithms for Medical Surface Models," 0031 % Simulation and Visualization, pp. 289-304, 2006. 0032 % 0033 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net) 0034 % 0035 0036 p=node; 0037 if(isempty(mask)) 0038 nn=size(node,1); 0039 idx=1:nn; 0040 else 0041 idx=find(mask==0)'; 0042 nn=length(idx); 0043 end 0044 alpha=0.5; 0045 method='laplacian'; 0046 beta=0.5; 0047 if(nargin>4) 0048 alpha=useralpha; 0049 if(nargin>5) 0050 method=usermethod; 0051 if(nargin>6) 0052 beta=userbeta; 0053 end 0054 end 0055 end 0056 ibeta=1-beta; 0057 ialpha=1-alpha; 0058 0059 for i=1:nn 0060 if(length(conn{idx(i)})==0) 0061 idx(i)=0; 0062 end 0063 end 0064 idx=idx(idx>0); 0065 nn=length(idx); 0066 0067 if(strcmp(method,'laplacian')) 0068 for j=1:iter 0069 for i=1:nn 0070 p(idx(i),:)=ialpha*p(idx(i),:)+alpha*mean(node(conn{idx(i)},:)); 0071 end 0072 node=p; 0073 end 0074 elseif(strcmp(method,'laplacianhc')) 0075 for j=1:iter 0076 q=p; 0077 for i=1:nn 0078 p(idx(i),:)=mean(q(conn{idx(i)},:)); 0079 end 0080 b=p-(alpha*node+ialpha*q); 0081 for i=1:nn 0082 p(idx(i),:)=p(idx(i),:)-(beta*b(i,:)+ibeta*mean(b(conn{idx(i)},:))); 0083 end 0084 end 0085 elseif(strcmp(method,'lowpass')) 0086 beta=-1.02*alpha; 0087 ibeta=1-beta; 0088 for j=1:iter 0089 for i=1:nn 0090 p(idx(i),:)=ialpha*node(idx(i),:)+alpha*mean(node(conn{idx(i)},:)); 0091 end 0092 node=p; 0093 for i=1:nn 0094 p(idx(i),:)=ibeta *node(idx(i),:)+beta *mean(node(conn{idx(i)},:)); 0095 end 0096 node=p; 0097 end 0098 end