Mercurial > hg > octave-image
changeset 668:7b6b493d66b5
imdilate: fix tests for uneven structuring elements
author | carandraug |
---|---|
date | Thu, 08 Nov 2012 16:43:19 +0000 |
parents | 8b7cd6e22704 |
children | 73e3dbfbb397 |
files | inst/dilate.m inst/imdilate.m |
diffstat | 2 files changed, 9 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/inst/dilate.m +++ b/inst/dilate.m @@ -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/inst/imdilate.m +++ b/inst/imdilate.m @@ -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]);