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