forked from fangq/iso2mesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deislands3d.m
35 lines (32 loc) · 926 Bytes
/
deislands3d.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function cleanimg=deislands3d(img,sizelim)
%
% 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)
%
maxisland=-1;
if(nargin==2) maxisland=sizelim; end
for i=1:size(img,1)
if(mod(i,10)==0) fprintf(1,'processing slice x=%d\n',i); end
img(i,:,:)=deislands2d(img(i,:,:),maxisland);
end
for i=1:size(img,2)
if(mod(i,10)==0) fprintf(1,'processing slice y=%d\n',i); end
img(:,i,:)=deislands2d(img(:,i,:),maxisland);
end
for i=1:size(img,3)
if(mod(i,10)==0) fprintf(1,'processing slice z=%d\n',i); end
img(:,:,i)=deislands2d(img(:,:,i),maxisland);
end
cleanimg=img;