Home > vbmeg > external > iso2mesh > sample > demo_mesh_smoothing.m

demo_mesh_smoothing

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   demo script for surface smoothing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0002 %   demo script for surface smoothing
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 
0005 %% preparation
0006 % user must add the path of iso2mesh to matlab path list
0007 % addpath('../');
0008 
0009 % user need to add the full path to .../iso2mesh/bin directory
0010 % to windows/Linux/Unix PATH environment variable
0011 
0012 %% load the sample data
0013 load rat_head.mat
0014 
0015 % volimage is a volumetric image such as an X-ray or MRI image
0016 % A,b are registration matrix and vector, respectively
0017 %% perform mesh generation
0018 
0019 [node,face]=v2s(volimage,0.5,2,'cgalmesh');
0020 
0021 face=face(:,1:3);
0022 
0023 p0=min(node);
0024 p1=max(node);
0025 
0026 rownum=3;
0027 colnum=4;
0028 figure;
0029 subplot(rownum,colnum,1);
0030 
0031 plotmesh(node,face(:,1:3));
0032 if(~isoctavemesh) 
0033     title({'Laplacian+HC Smoothing Test','no smoothing'}); 
0034 else
0035     title('Laplacian+HC - no smoothing');
0036 end
0037 axis equal;
0038 set(gca,'xlim',[p0(1),p1(1)],'ylim',[p0(2),p1(2)],'zlim',[p0(3),p1(3)])
0039 
0040 %=========================================================
0041 % apply Laplacian+HC smoothing
0042 %=========================================================
0043 
0044 n1=node;
0045 for i=1:rownum*colnum-1
0046   n1=sms(n1,face(:,1:3),1,0.5); % apply Laplacian+HC mesh smoothing
0047   subplot(rownum,colnum,i+1);
0048   plotmesh(n1,face(:,1:3));
0049   title(['iter=' num2str(i)]);
0050   axis equal;
0051   set(gca,'xlim',[p0(1),p1(1)],'ylim',[p0(2),p1(2)],'zlim',[p0(3),p1(3)])
0052 end
0053 
0054 %=========================================================
0055 % apply Laplacian smoothing
0056 %=========================================================
0057 
0058 figure;
0059 subplot(rownum,colnum,1);
0060 
0061 plotmesh(node,face(:,1:3));
0062 if(~isoctavemesh)
0063         title({'Laplacian Smoothing Test','no smoothing'});
0064 else
0065         title('Laplacian - no smoothing');
0066 end
0067 axis equal;
0068 set(gca,'xlim',[p0(1),p1(1)],'ylim',[p0(2),p1(2)],'zlim',[p0(3),p1(3)])
0069 
0070 conn=meshconn(face(:,1:3),size(node,1));
0071 
0072 n1=node;
0073 for i=1:rownum*colnum-1
0074   n1=smoothsurf(n1,[],conn,1,0.5,'laplacian');
0075   subplot(rownum,colnum,i+1);
0076   plotmesh(n1,face(:,1:3));
0077   title(['iter=' num2str(i)]);
0078   axis equal;
0079   set(gca,'xlim',[p0(1),p1(1)],'ylim',[p0(2),p1(2)],'zlim',[p0(3),p1(3)])
0080 end
0081 
0082 
0083 %=========================================================
0084 % apply Low-pass smoothing
0085 %=========================================================
0086 
0087 figure;
0088 subplot(rownum,colnum,1);
0089 
0090 plotmesh(node,face(:,1:3));
0091 if(~isoctavemesh)
0092         title({'Low-pass Smoothing Test','no smoothing'});
0093 else
0094         title('Low-pass - no smoothing');
0095 end
0096 axis equal;
0097 set(gca,'xlim',[p0(1),p1(1)],'ylim',[p0(2),p1(2)],'zlim',[p0(3),p1(3)])
0098 
0099 conn=meshconn(face(:,1:3),size(node,1));
0100 
0101 n1=node;
0102 for i=1:rownum*colnum-1
0103   n1=smoothsurf(n1,[],conn,1,0.5,'lowpass');
0104   subplot(rownum,colnum,i+1);
0105   plotmesh(n1,face(:,1:3));
0106   title(['iter=' num2str(i)]);
0107   axis equal;
0108   set(gca,'xlim',[p0(1),p1(1)],'ylim',[p0(2),p1(2)],'zlim',[p0(3),p1(3)])
0109 end
0110

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005