vol=thickenbinvol(vol,layer) thickening a binary volume by a given pixel width this is similar to bwmorph(vol,'thicken',3) except this does it in 3d and only does thickening for non-zero elements (and hopefully faster) author: Qianqian Fang, <q.fang at neu.edu> input: vol: a volumetric binary image layer: number of iterations for the thickenining output: vol: the volume image after the thickening -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0001 function vol=thickenbinvol(vol,layer) 0002 % 0003 % vol=thickenbinvol(vol,layer) 0004 % 0005 % thickening a binary volume by a given pixel width 0006 % this is similar to bwmorph(vol,'thicken',3) except 0007 % this does it in 3d and only does thickening for 0008 % non-zero elements (and hopefully faster) 0009 % 0010 % author: Qianqian Fang, <q.fang at neu.edu> 0011 % 0012 % input: 0013 % vol: a volumetric binary image 0014 % layer: number of iterations for the thickenining 0015 % 0016 % output: 0017 % vol: the volume image after the thickening 0018 % 0019 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net) 0020 % 0021 0022 dim=size(vol); 0023 dxy=dim(1)*dim(2); 0024 fulllen=prod(dim); 0025 0026 offs=[1,-1,dim(1),-dim(1),dxy,-dxy]; 0027 for i=1:layer 0028 idx=find(vol); 0029 for j=1:6 0030 idxnew=idx+offs(j); 0031 idxnew=idxnew(find(idxnew>0 & idxnew<fulllen)); 0032 vol(idxnew)=1; 0033 end 0034 end