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} = imopen (@var{A}, @var{se})
15 ## Perform morphological opening 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 opening corresponds to an erosion followed by a dilation of the image, i.e.
21 ## B = imdilate(imerode(A, se), se);
23 ## @seealso{imdilate, imerode, imclose}
26 function retval = imopen(im, se)
31 if (!ismatrix(im) || !isreal(im))
32 error("imopen: first input argument must be a real matrix");
34 if (!ismatrix(se) || !isreal(se))
35 error("imopen: second input argument must be a real matrix");
39 retval = imdilate(imerode(im, se), se);