# HG changeset patch # User John W. Eaton # Date 1624374511 14400 # Node ID 10408a66305b71d8cc1311a5c650a7c7eab7a9d8 # Parent d2294eff51803c1b570d9b729a8a85373fb00da6# Parent df8982134c3be213d8577791d926bada4e74bdc6 maint: Merge stable to default. diff -r d2294eff5180 -r 10408a66305b scripts/image/rgb2ind.m --- a/scripts/image/rgb2ind.m Tue Jun 22 00:34:15 2021 -0400 +++ b/scripts/image/rgb2ind.m Tue Jun 22 11:08:31 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");