Mercurial > hg > octave-image
changeset 580:cc447688e3f6
iscolormap: also check class and number of dimensions
author | carandraug |
---|---|
date | Sun, 02 Sep 2012 03:52:17 +0000 |
parents | cad86b82d447 |
children | 56faf308f3d0 |
files | inst/iptcheckmap.m inst/iscolormap.m |
diffstat | 2 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/inst/iptcheckmap.m +++ b/inst/iptcheckmap.m @@ -43,7 +43,7 @@ ## error ends in \n so the back trace of the error is not show. This is on ## purpose since the whole idea of this function is already to give a properly ## formatted error message - if (!strcmp (class(in), "double") || columns (in) != 3 || ndims (in) != 2 || !isreal (in) || min (in(:) < 0) || max (in(:) > 1)) + if (!iscolormap (in)) error ("Function %s expected input number %d, %s, to be a valid colormap.\n... Valid colormaps must be nonempty, double, 2-D matrices with 3 columns.\n", ... func_name, pos, var_name);
--- a/inst/iscolormap.m +++ b/inst/iscolormap.m @@ -31,7 +31,8 @@ endif bool = false; - if (ismatrix (cm) && isnumeric (cm) && columns(cm) == 3 && + if (ismatrix (cm) && isreal (cm) isnumeric (cm) && columns(cm) == 3 && + ndims (cm) == 2 && strcmp (class (cm), "double") && min (cm(:)) >= 0 && max (cm(:)) <= 1) bool = true; endif