Mercurial > octave
changeset 29801:df8982134c3b stable
reduce memory usage and eliminate randomness in rgb2ind test
* rgb2ind.m: Use nchoosek instead of rand to create matrices with
unique sets of elements.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 22 Jun 2021 11:07:49 -0400 |
parents | 213fa6186990 |
children | 10408a66305b 20380c9bed30 |
files | scripts/image/rgb2ind.m |
diffstat | 1 files changed, 15 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/image/rgb2ind.m Mon Jun 21 16:23:05 2021 -0400 +++ b/scripts/image/rgb2ind.m Tue Jun 22 11:07:49 2021 -0400 @@ -130,20 +130,29 @@ ## Test output class %!test -%! ## this should have more than 65536 unique colors -%! rgb = rand (1000, 1000, 3); +%! ## this should have more than 65535 unique colors +%! rgb = nchoosek (0:80, 3) / 80; +%! nr = rows (rgb) +%! assert (nr > 65535); +%! rgb = reshape (rgb, [1, nr, 3]); %! [ind, map] = rgb2ind (rgb); %! assert (class (ind), "double"); %! assert (class (map), "double"); %! -%! ## and this should have between 255 and 65536 unique colors -%! rgb = rand (20, 20, 3); +%! ## and this should have between 256 and 65535 unique colors +%! rgb = nchoosek (0:40, 3) / 80; +%! nr = rows (rgb) +%! assert (nr >= 256 && nr <= 65535); +%! rgb = reshape (rgb, [1, nr, 3]); %! [ind, map] = rgb2ind (rgb); %! assert (class (ind), "uint16"); %! assert (class (map), "double"); %! -%! ## and this certainly less than 256 unique colors -%! rgb = rand (10, 10, 3); +%! ## and this one should have fewer than than 256 unique colors +%! rgb = nchoosek (0:10, 3) / 80; +%! nr = rows (rgb) +%! assert (nr < 256); +%! rgb = reshape (rgb, [1, nr, 3]); %! [ind, map] = rgb2ind (rgb); %! assert (class (ind), "uint8"); %! assert (class (map), "double");