cleanimg=deislands3d(img,sizelim) remove isolated islands for 3D image (for each slice) author: Qianqian Fang, <q.fang at neu.edu> input: img: a 3D volumetric image sizelim: maximum island size (in pixels) for each x/y/z slice output: cleanimg: 3D image after removing the islands -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0001 function cleanimg=deislands3d(img,sizelim) 0002 % 0003 % cleanimg=deislands3d(img,sizelim) 0004 % 0005 % remove isolated islands for 3D image (for each slice) 0006 % 0007 % author: Qianqian Fang, <q.fang at neu.edu> 0008 % 0009 % input: 0010 % img: a 3D volumetric image 0011 % sizelim: maximum island size (in pixels) for each x/y/z slice 0012 % 0013 % output: 0014 % cleanimg: 3D image after removing the islands 0015 % 0016 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net) 0017 % 0018 0019 maxisland=-1; 0020 if(nargin==2) maxisland=sizelim; end 0021 0022 for i=1:size(img,1) 0023 if(mod(i,10)==0) fprintf(1,'processing slice x=%d\n',i); end 0024 img(i,:,:)=deislands2d(img(i,:,:),maxisland); 0025 end 0026 for i=1:size(img,2) 0027 if(mod(i,10)==0) fprintf(1,'processing slice y=%d\n',i); end 0028 img(:,i,:)=deislands2d(img(:,i,:),maxisland); 0029 end 0030 for i=1:size(img,3) 0031 if(mod(i,10)==0) fprintf(1,'processing slice z=%d\n',i); end 0032 img(:,:,i)=deislands2d(img(:,:,i),maxisland); 0033 end 0034 0035 cleanimg=img;