# HG changeset patch # User Avinam # Date 1447880175 -7200 # Wed Nov 18 22:56:15 2015 +0200 # Node ID 4770e79c8fa067d322b0d7c3c92788bb1b75882c # Parent ecd0a9e0be25e9998c3b75e29cee6a865743f913 im2bw.m: adding more BIST * inst/im2bw.m: adding more test for int16 and uint16 diff -r ecd0a9e0be25 -r 4770e79c8fa0 inst/im2bw.m --- a/inst/im2bw.m Wed Nov 18 14:37:31 2015 +0000 +++ b/inst/im2bw.m Wed Nov 18 22:56:15 2015 +0200 @@ -128,3 +128,19 @@ ## threshold may be a negative value in the image class so care must ## taken when casting and rounding it. %!assert (nnz (im2bw (int16 ([-128:127]), 0.499)), 194) +%!assert (nnz (im2bw (int16 ([-128:127]), 0.500)), 128) +%!assert (nnz (im2bw (int16 ([-128:127]), 0.501)), 62) +%! +%! img = uint16 ([0:intmax("uint16")]); +%! s = 0; +%! for i=0:.1:1 +%! s += nnz (im2bw (img, i)); +%! endfor +%! assert (s, 360445) +%! +%! img = int16 ([intmin("int16"):intmax("int16")]); +%! s = 0; +%! for i=0:.1:1 +%! s += nnz (im2bw (img, i)); +%! endfor +%! assert (s, 360445)