changeset 11221:5c65f18d6d02 octave-forge

imdilate: fix tests for uneven structuring elements
author carandraug
date Thu, 08 Nov 2012 16:43:19 +0000
parents f071ba771468
children 4129b6e604cb
files main/image/inst/dilate.m main/image/inst/imdilate.m
diffstat 2 files changed, 9 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/main/image/inst/dilate.m	Thu Nov 08 16:29:38 2012 +0000
+++ b/main/image/inst/dilate.m	Thu Nov 08 16:43:19 2012 +0000
@@ -84,12 +84,3 @@
 
   BW2=BW1;
 endfunction
-
-%!demo
-%! dilate(eye(5),ones(2,2))
-%! % returns a thick diagonal.
-
-## tests
-%!assert(dilate(eye(3),[1])==eye(3));                     # using [1] as a mask returns the same value
-%!assert(dilate(eye(3),[1,0,0])==[0,0,0;1,0,0;0,1,0]);    # check if it works with non-symmetric SE
-%!assert(dilate(eye(3),[1,0,0,0])==[0,0,0;1,0,0;0,1,0]);  # test if center is correctly calculated on even masks
--- a/main/image/inst/imdilate.m	Thu Nov 08 16:29:38 2012 +0000
+++ b/main/image/inst/imdilate.m	Thu Nov 08 16:43:19 2012 +0000
@@ -64,6 +64,12 @@
 %! imdilate(eye(5),ones(2,2))
 %! % returns a thick diagonal.
 
-%!assert(imdilate(eye(3),[1])==eye(3));                     # using [1] as a mask returns the same value
-%!assert(imdilate(eye(3),[1,0,0])==[0,0,0;1,0,0;0,1,0]);    # check if it works with non-symmetric SE
-%!assert(imdilate(eye(5),[1,0,0,0])==[0,0,0,0,0;1,0,0,0,0;0,1,0,0,0;0,0,1,0,0;0,0,0,1,0]); # test if center is correctly calculated on even masks
+%!assert(imdilate(eye(3),[1]), eye(3));                     # using [1] as a mask returns the same value
+%!assert(logical(imdilate(eye(3),[1])), logical(eye(3)));   # same with logical matrix
+%!assert(imdilate(eye(3),[1,0,0]), [0,0,0;1,0,0;0,1,0]);                            # check if it works with non-symmetric SE
+%!assert(imdilate(logical(eye(3)),logical([1,0,0])), logical([0,0,0;1,0,0;0,1,0])); # same with logical matrix
+## test if center is correctly calculated on even masks. There's no right way,
+
+## it all depends what is considered the center of the structuring element. The
+## expected answer here is what Matlab does
+%!xtest assert(imdilate(eye(5),[1,0,0,0]), [0,0,0,0,0;1,0,0,0,0;0,1,0,0,0;0,0,1,0,0;0,0,0,1,0]);