0001
0002
0003
0004
0005
0006
0007
0008 fprintf(1,'loading binary head image...\n');
0009 for i=1:256
0010 head(:,:,i)=imread('head.tif',i);
0011 end
0012
0013
0014 fprintf(1,'loading binary brain image...\n');
0015 for i=1:256
0016 brain(:,:,i)=imread('brain.tif',i);
0017 end
0018
0019
0020
0021 fprintf(1,'filling holes in the volumetric images...\n');
0022 tic
0023 cleanimg=fillholes3d(logical(head>0),10);
0024 cleanbrain=fillholes3d(logical(brain>0),10);
0025 toc
0026
0027
0028 cleanimgfull=cleanimg+(cleanbrain>0);
0029
0030
0031
0032 clear opt;
0033
0034
0035 opt(1).keepratio=0.05;
0036 opt(2).keepratio=0.1;
0037
0038
0039 opt(1).radbound=4;
0040 opt(2).radbound=2;
0041 opt(1).side='lower';
0042 opt(2).side='lower';
0043
0044 tic
0045 [node,elem,face]=vol2mesh(cleanimgfull,1:size(cleanimg,1),1:size(cleanimg,2),1:size(cleanimg,3),opt,100,1);
0046 toc
0047
0048
0049 h=slice(cleanimgfull,[],[120],[120 180]);
0050 set(h,'linestyle','none')
0051 hold on
0052
0053 plotmesh(node(:,[2 1 3]),face,'facealpha',0.7);