changeset 29802:10408a66305b

maint: Merge stable to default.
author John W. Eaton <jwe@octave.org>
date Tue, 22 Jun 2021 11:08:31 -0400
parents d2294eff5180 (current diff) df8982134c3b (diff)
children 540f25090412
files scripts/image/rgb2ind.m
diffstat 1 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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");