changeset 15515:4beb3a4bd440

rgbplot.m, cmpermute.m, cmunique.m, ind2rgb.m, imwrite.m: use core iscolormap function
author Carnë Draug <carandraug+dev@gmail.com>
date Fri, 12 Oct 2012 23:11:08 +0200
parents 8d64e87c00cf
children 271f0a2d15ab
files scripts/image/cmpermute.m scripts/image/cmunique.m scripts/image/imwrite.m scripts/image/ind2rgb.m scripts/image/rgbplot.m
diffstat 5 files changed, 8 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/image/cmpermute.m	Fri Oct 12 23:08:55 2012 +0200
+++ b/scripts/image/cmpermute.m	Fri Oct 12 23:11:08 2012 +0200
@@ -54,9 +54,7 @@
     error ("cmpermute: X must be an indexed image");
   endif
 
-  if (! isnumeric (map) || iscomplex (map)
-      || ndims (map) != 2 || columns (map) != 3
-      || any (map(:) < 0) || any (map(:) > 1))
+  if (! iscolormap (map))
     error ("cmpermute: MAP must be a valid colormap");
   endif
 
--- a/scripts/image/cmunique.m	Fri Oct 12 23:08:55 2012 +0200
+++ b/scripts/image/cmunique.m	Fri Oct 12 23:11:08 2012 +0200
@@ -68,9 +68,7 @@
 
   if (nargin == 2)
     ## (X, map) case
-    if (! isnumeric (map) || iscomplex (map)
-        || ndims (map) != 2 || columns (map) != 3
-        || any (map(:) < 0) || any (map(:) > 1))
+    if (! iscolormap (map))
       error ("cmunique: MAP must be a valid colormap");
     endif
     [newmap,i,j] = unique (map, "rows");  # calculate unique colormap
--- a/scripts/image/imwrite.m	Fri Oct 12 23:08:55 2012 +0200
+++ b/scripts/image/imwrite.m	Fri Oct 12 23:11:08 2012 +0200
@@ -161,13 +161,8 @@
     else
       error ("imwrite: %s: invalid class for indexed image data", img_class);
     endif
-    if (isa (map, "double"))
-      if (ndims (map) != 2 || columns (map) != 3)
-        error ("imwrite: invalid size for colormap");
-      endif
-    else
-      error ("imwrite: %s invalid class for indexed image colormap",
-             class (map));
+    if (! iscolormap (map))
+      error ("imwrite: invalid indexed image colormap");
     endif
 
     ## FIXME -- we should really be writing indexed images here but
--- a/scripts/image/ind2rgb.m	Fri Oct 12 23:08:55 2012 +0200
+++ b/scripts/image/ind2rgb.m	Fri Oct 12 23:11:08 2012 +0200
@@ -46,7 +46,7 @@
   endif
 
   ## Check the color map.
-  if (ndims (map) != 2 || columns (map) != 3)
+  if (! iscolormap (map))
     error ("ind2rgb: MAP must be a valid colormap");
   endif
 
--- a/scripts/image/rgbplot.m	Fri Oct 12 23:08:55 2012 +0200
+++ b/scripts/image/rgbplot.m	Fri Oct 12 23:11:08 2012 +0200
@@ -32,10 +32,8 @@
     print_usage ();
   endif
 
-  if (! ismatrix (cmap) || ndims (cmap) != 2 || columns (cmap) != 3)
-    error ("rgbplot: CMAP must be a matrix of size Nx3");
-  elseif (any (cmap(:) < 0) || any (cmap(:) > 1))
-    error ("rgbplot: CMAP intensities must be in the range [0, 1]");
+  if (! iscolormap (cmap))
+    error ("rgbplot: CMAP must be a colormap");
   endif
 
   plot (cmap(:,1),"r", cmap(:,2),"g", cmap(:,3),"b");
@@ -52,9 +50,4 @@
 %%test input validation
 %!error rgbplot ()
 %!error rgbplot (1,2)
-%!error <CMAP must be a matrix of size Nx3> rgbplot ({0 1 0})
-%!error <CMAP must be a matrix of size Nx3> rgbplot (ones (3,3,3))
-%!error <CMAP must be a matrix of size Nx3> rgbplot (ones (3,4))
-%!error <CMAP intensities must be in the range> rgbplot ([0 0 -2])
-%!error <CMAP intensities must be in the range> rgbplot ([0 0 2])
-
+%!error <CMAP must be a colormap> rgbplot ({0 1 0})