# HG changeset patch # User carandraug # Date 1281715194 0 # Node ID e6fcf4a6e06c5d2a67db987d808cfef493ede90c # Parent 9acda5798f6fbb6fa76497d5345eff8a5dea2aea Faster and easier bug fix for bug when using non-symmetrical SE. Only need to rotate the SE before the filtering diff --git a/inst/imdilate.m b/inst/imdilate.m --- a/inst/imdilate.m +++ b/inst/imdilate.m @@ -30,21 +30,10 @@ error("imdilate: second input argument must be a real matrix"); endif - if (isinteger(im)) - padding = intmax(class(im)); - elseif (islogical(im)) - padding = logical(1); - elseif (isreal(im)) - padding = Inf; - else - error("Unexpected class for the image. Must be logical, integer ou real matrix") - endif - ## Perform filtering - ## Dilation of A by B is the erosion of A's complement by the reflection of B - ## Since erosion will be performed in the complement, padding must also be the - ## complement of zero + ## Filtering must be done with the reflection of the structuring element (they + ## are not always symmetrical) se = imrotate(se, 180); - retval = !ordfiltn(!im, 1, se, padding); + retval = ordfiltn(im, sum(se(:)!=0), se, 0); endfunction