Mercurial > hg > octave-image
changeset 451:e0fc9967fcf0
Bug fix where double precision would be returned when arguments were of logical class
author | carandraug |
---|---|
date | Wed, 13 Apr 2011 23:58:55 +0000 |
parents | 43974138fa93 |
children | 3318f6ec2087 |
files | inst/imtophat.m |
diffstat | 1 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/inst/imtophat.m +++ b/inst/imtophat.m @@ -46,10 +46,21 @@ endif ## Perform filtering + ## Note that in case that the transform is to applied to a logical image, + ## subtraction must be handled in a different way (x & !y) instead of (x - y) + ## or it will return a double precision matrix if ( strcmpi(trans, "white") || strcmpi(trans, "open") ) - retval = im - imopen(im, se); + if (islogical(im)) + retval = im & !imopen(im,se); + else + retval = im - imopen(im, se); + endif elseif ( strcmpi(trans, "black") || strcmpi(trans, "close") ) - retval = imclose(im, se) - im; + if (islogical(im)) + retval = imclose(im, se) & !im; + else + retval = imclose(im, se) - im; + endif else error ("Unexpected type of top-hat transform"); endif