1 ## Copyright (C) 2008 Soren Hauberg
3 ## This program is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU General Public License
5 ## as published by the Free Software Foundation; either version 2
6 ## of the License, or (at your option) any later version.
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ## GNU General Public License for more details.
14 ## @deftypefn {Function File} @var{B} = imclose (@var{A}, @var{se})
15 ## Perform morphological closing on a given image.
16 ## The image @var{A} must be a grayscale or binary image, and @var{se} must be a
17 ## structuring element.
19 ## The closing corresponds to a dilation followed by an erosion of the image, i.e.
21 ## B = imerode(imdilate(A, se), se);
23 ## @seealso{imdilate, imerode, imclose}
26 function retval = imclose(im, se)
31 if (!ismatrix(im) || !isreal(im))
32 error("imclose: first input argument must be a real matrix");
34 if (!ismatrix(se) || !isreal(se))
35 error("imclose: second input argument must be a real matrix");
39 retval = imerode(imdilate(im, se), se);