]> Creatis software - CreaPhase.git/blob - octave_packages/image-1.0.15/imclose.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / image-1.0.15 / imclose.m
1 ## Copyright (C) 2008 Soren Hauberg
2 ## 
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.
7 ## 
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.
12
13 ## -*- texinfo -*-
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.
18 ##
19 ## The closing corresponds to a dilation followed by an erosion of the image, i.e.
20 ## @example
21 ## B = imerode(imdilate(A, se), se);
22 ## @end example
23 ## @seealso{imdilate, imerode, imclose}
24 ## @end deftypefn
25
26 function retval = imclose(im, se)
27   ## Checkinput
28   if (nargin != 2)
29     print_usage();
30   endif
31   if (!ismatrix(im) || !isreal(im))
32     error("imclose: first input argument must be a real matrix");
33   endif
34   if (!ismatrix(se) || !isreal(se))
35     error("imclose: second input argument must be a real matrix");
36   endif
37   
38   ## Perform filtering
39   retval = imerode(imdilate(im, se), se);
40
41 endfunction