Mercurial > hg > octave-image
changeset 455:af2072711ff1
Added checks if image and SE have the same class
author | carandraug |
---|---|
date | Thu, 14 Apr 2011 00:49:06 +0000 |
parents | 9eef309640e5 |
children | 5229605d509a |
files | inst/imdilate.m inst/imerode.m |
diffstat | 2 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/inst/imdilate.m +++ b/inst/imdilate.m @@ -15,8 +15,11 @@ ## -*- texinfo -*- ## @deftypefn {Function File} @var{B} = imdilate (@var{A}, @var{se}) ## Perform morphological dilation on a given image. +## ## The image @var{A} must be a grayscale or binary image, and @var{se} must be a -## structuring element. +## structuring element. Both must have the same class, e.g., if @var{A} is a +## logical matrix, @var{se} must also be logical. +## ## @seealso{imerode, imopen, imclose} ## @end deftypefn @@ -27,9 +30,10 @@ endif if (!ismatrix(im) || !isreal(im)) error("imdilate: first input argument must be a real matrix"); - endif - if (!ismatrix(se) || !isreal(se)) + elseif (!ismatrix(se) || !isreal(se)) error("imdilate: second input argument must be a real matrix"); + elseif ( !strcmp(class(im), class(se)) ) + error("imdilate: image and structuring element must have the same class"); endif ## Perform filtering
--- a/inst/imerode.m +++ b/inst/imerode.m @@ -15,8 +15,11 @@ ## -*- texinfo -*- ## @deftypefn {Function File} @var{B} = imerode (@var{A}, @var{se}) ## Perform morphological erosion on a given image. +## ## The image @var{A} must be a grayscale or binary image, and @var{se} must be a -## structuring element. +## structuring element. Both must have the same class, e.g., if @var{A} is a +## logical matrix, @var{se} must also be logical. +## ## @seealso{imdilate, imopen, imclose} ## @end deftypefn @@ -27,9 +30,10 @@ endif if (!ismatrix(im) || !isreal(im)) error("imerode: first input argument must be a real matrix"); - endif - if (!ismatrix(se) || !isreal(se)) + elseif (!ismatrix(se) || !isreal(se)) error("imerode: second input argument must be a real matrix"); + elseif ( !strcmp(class(im), class(se)) ) + error("imerode: image and structuring element must have the same class"); endif ## Perform filtering