forked from fangq/iso2mesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfillholes3d.m
36 lines (34 loc) · 807 Bytes
/
fillholes3d.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
36
function resimg=fillholes3d(img,maxgap)
%
% resimg=fillholes3d(img,maxgap)
%
% close a 3D image with the speicified gap size and then fill the holes
%
% author: Qianqian Fang, <q.fang at neu.edu>
%
% input:
% img: a 3D binary image
% maxgap: maximum gap size for image closing
%
% output:
% resimg: the image free of holes
%
% this function requires the image processing toolbox for matlab/octave
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%
if(maxgap)
resimg = imclose(img,strel(ones(maxgap,maxgap,maxgap)));
else
resimg=img;
end
if(isoctavemesh)
if(~exist('bwfill'))
error('you need to install octave-image toolbox first');
end
for i=1:size(resimg,3)
resimg(:,:,i)=bwfill(resimg(:,:,i),'holes');
end
else
resimg=imfill(resimg,'holes');
end