# HG changeset patch # User Carnë Draug # Date 1350076268 -7200 # Node ID 4beb3a4bd4400171f56267feab1159a00105d3a7 # Parent 8d64e87c00cf8cef0ab6592c235b63543ce8c4fa rgbplot.m, cmpermute.m, cmunique.m, ind2rgb.m, imwrite.m: use core iscolormap function diff --git a/scripts/image/cmpermute.m b/scripts/image/cmpermute.m --- a/scripts/image/cmpermute.m +++ b/scripts/image/cmpermute.m @@ -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 diff --git a/scripts/image/cmunique.m b/scripts/image/cmunique.m --- a/scripts/image/cmunique.m +++ b/scripts/image/cmunique.m @@ -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 diff --git a/scripts/image/imwrite.m b/scripts/image/imwrite.m --- a/scripts/image/imwrite.m +++ b/scripts/image/imwrite.m @@ -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 diff --git a/scripts/image/ind2rgb.m b/scripts/image/ind2rgb.m --- a/scripts/image/ind2rgb.m +++ b/scripts/image/ind2rgb.m @@ -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 diff --git a/scripts/image/rgbplot.m b/scripts/image/rgbplot.m --- a/scripts/image/rgbplot.m +++ b/scripts/image/rgbplot.m @@ -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 rgbplot ({0 1 0}) -%!error rgbplot (ones (3,3,3)) -%!error rgbplot (ones (3,4)) -%!error rgbplot ([0 0 -2]) -%!error rgbplot ([0 0 2]) - +%!error rgbplot ({0 1 0})