Mercurial > octave-nkf
diff scripts/image/ind2gray.m @ 18578:875f4510d6dc
Accept indexed images with color values below the first colormap entry (bug #41851).
Change made for Matlab compatibility.
* ind2gray.m: Change %!tests to accept an indexed image with colors below the
first entry in the colormap.
* ind2rgb.m: Change %!tests to accept an indexed image with colors below the
first entry in the colormap.
* ind2x.m: Change input validation to accept all floating point images with integer
indices. Issue a warning if any of the indices are below the first entry in the
colormap. Map all color indices below the first entry to the first color in the
colormap.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 17 Mar 2014 09:10:32 -0700 |
parents | d63878346099 |
children | 0e1f5a750d00 |
line wrap: on
line diff
--- a/scripts/image/ind2gray.m Sun Mar 16 11:44:11 2014 -0700 +++ b/scripts/image/ind2gray.m Mon Mar 17 09:10:32 2014 -0700 @@ -69,18 +69,19 @@ %!shared i2g %! i2g = ind2gray (1:100, gray (100)); -%!assert (i2g, 0:1/99:1, eps); -%!assert (gray2ind (i2g, 100), uint8 (0:99)); +%! +%!assert (i2g, 0:1/99:1, eps) +%!assert (gray2ind (i2g, 100), uint8 (0:99)) %% Test input validation %!error ind2gray () %!error ind2gray (1) %!error ind2gray (1,2,3) -%!error <X must be an indexed image> ind2gray ({1}, jet (64)) +%!error <X must be an indexed image> ind2gray (ones (3,3,3), jet (64)) %!error <X must be an indexed image> ind2gray (1+i, jet (64)) %!error <X must be an indexed image> ind2gray (sparse (1), jet (64)) -%!error <X must be an indexed image> ind2gray (0, jet (64)) %!error <X must be an indexed image> ind2gray (1.1, jet (64)) +%!error <X must be an indexed image> ind2gray ({1}, jet (64)) %!error <MAP must be a valid colormap> ind2gray (1, {1}) %!error <MAP must be a valid colormap> ind2gray (1, 1+i) %!error <MAP must be a valid colormap> ind2gray (1, ones (2,2,2)) @@ -88,3 +89,7 @@ %!error <MAP must be a valid colormap> ind2gray (1, [-1]) %!error <MAP must be a valid colormap> ind2gray (1, [2]) +%!warning <contains colors outside of colormap> ind2gray ([0 1 2], gray (5)); +%!warning <contains colors outside of colormap> ind2gray ([1 2 6], gray (5)); +%!warning <contains colors outside of colormap> ind2gray (uint8 ([1 2 5]), gray (5)); +