diff scripts/image/iscolormap.m @ 20392:a3bf503652b2

iscolormap: relax input check - specially in [0 1] range. * scripts/image/iscolormap.m: relax input check. Allow for colormap of class single and values outside the [0 1] range. What to do in the case of values outside the [0 1] will need to be a per-function choice, in order to meet Matlab compatibility. Also, not Matlab supported, a colormap could perfectly be of class integer. * scripts/image/cmpermute.m, scripts/image/cmunique.m, scripts/image/imshow.m: add input check for values outside the [0 1] range.
author Carnë Draug <carandraug@octave.org>
date Thu, 16 Jul 2015 18:21:27 +0100
parents 7503499a252b
children
line wrap: on
line diff
--- a/scripts/image/iscolormap.m	Thu Jul 16 10:57:34 2015 -0400
+++ b/scripts/image/iscolormap.m	Thu Jul 16 18:21:27 2015 +0100
@@ -22,7 +22,12 @@
 ##
 ## A colormap is a real matrix with @var{n} rows and 3 columns.  Each row
 ## represents a single color.  The columns contain red, green, and blue
-## intensities respectively.  All entries must be between 0 and 1 inclusive.
+## intensities respectively.
+##
+## All values in a colormap should be in the [0 1] range but this is not
+## enforced.  Each function must decide what to do for values outside this
+## range.
+##
 ## @seealso{colormap, rgbplot}
 ## @end deftypefn
 
@@ -34,19 +39,14 @@
     print_usage;
   endif
 
-  retval = (isnumeric (cmap) && isreal (cmap) && ndims (cmap) == 2
-            && columns (cmap) == 3 && isa (cmap, "double")
-            && min (cmap(:)) >= 0 && max (cmap(:)) <= 1);
+  retval = (isnumeric (cmap) && isreal (cmap)
+            && ndims (cmap) == 2 && columns (cmap) == 3
+            && isfloat (cmap));
 
 endfunction
 
-
 %!assert (iscolormap (jet (64)))
 %!assert (iscolormap ({0 1 0}), false)
 %!assert (iscolormap ([0 1i 0]), false)
 %!assert (iscolormap (ones (3,3,3)), false)
 %!assert (iscolormap (ones (3,4)), false)
-%!assert (iscolormap (single (jet (64))), false)
-%!assert (iscolormap ([0 0 -2]), false)
-%!assert (iscolormap ([0 0 2]), false)
-