diff scripts/image/colormap.m @ 3238:041ea33fbbf4

[project @ 1999-03-26 17:48:16 by jwe]
author jwe
date Fri, 26 Mar 1999 17:48:35 +0000
parents 44d82b369c78
children 36405da8e173
line wrap: on
line diff
--- a/scripts/image/colormap.m	Sat Mar 06 07:44:55 1999 +0000
+++ b/scripts/image/colormap.m	Fri Mar 26 17:48:35 1999 +0000
@@ -42,20 +42,35 @@
   endif
 
   if (nargin == 1)
+
     if (isstr (map))
       if (strcmp (map, "default"))
-        __current_color_map__ = gray ();
+        map = gray ();
       else
-        error ("invalid argument");
+	unwind_protect
+	  save_default_eval_print_flag = default_eval_print_flag;
+	  default_eval_print_flag = 0;
+	  map = eval (map);
+	unwind_protect_cleanup
+	  default_eval_print_flag = save_default_eval_print_flag;
+	end_unwind_protect
       endif
-    else
+    endif
+
+    if (! isempty (map))
+      if (columns (map) != 3)
+	error( "colormap: map must have 3 columns: [R,G,B]." );
+      endif
+      if (min (min (map)) < 0 || max (max (map)) > 1)
+        error( "colormap: map must have values in [0,1]." );
+      endif
       ## Set the new color map
       __current_color_map__ = map;
     endif
+
   endif
 
   ## Return current color map.
-
   cmap = __current_color_map__;
 
 endfunction