Mercurial > hg > octave-image
annotate inst/iscolormap.m @ 580:cc447688e3f6
iscolormap: also check class and number of dimensions
author | carandraug |
---|---|
date | Sun, 02 Sep 2012 03:52:17 +0000 |
parents | c47fa2969872 |
children | bb0e1c085831 |
rev | line source |
---|---|
543 | 1 ## Copyright (C) 2012 Carnë Draug <carandraug+dev@gmail.com> |
2 ## | |
3 ## This program is free software; you can redistribute it and/or modify it under | |
4 ## the terms of the GNU General Public License as published by the Free Software | |
5 ## Foundation; either version 3 of the License, or (at your option) any later | |
6 ## version. | |
7 ## | |
8 ## This program is distributed in the hope that it will be useful, but WITHOUT | |
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
11 ## details. | |
12 ## | |
13 ## You should have received a copy of the GNU General Public License along with | |
14 ## this program; if not, see <http://www.gnu.org/licenses/>. | |
15 | |
16 ## -*- texinfo -*- | |
17 ## @deftypefn {Function File} {} iscolormap (@var{cm}) | |
18 ## Return true if @var{cm} is a colormap. | |
19 ## | |
20 ## A colormap is an @var{n} row by 3 column matrix. The columns contain red, | |
21 ## green, and blue intensities respectively. All entries should be between 0 | |
22 ## and 1 inclusive. | |
23 ## | |
24 ## @seealso{colormap} | |
25 ## @end deftypefn | |
26 | |
27 function bool = iscolormap (cm) | |
28 | |
29 if (nargin != 1) | |
30 print_usage; | |
31 endif | |
32 | |
33 bool = false; | |
580
cc447688e3f6
iscolormap: also check class and number of dimensions
carandraug
parents:
543
diff
changeset
|
34 if (ismatrix (cm) && isreal (cm) isnumeric (cm) && columns(cm) == 3 && |
cc447688e3f6
iscolormap: also check class and number of dimensions
carandraug
parents:
543
diff
changeset
|
35 ndims (cm) == 2 && strcmp (class (cm), "double") && |
543 | 36 min (cm(:)) >= 0 && max (cm(:)) <= 1) |
37 bool = true; | |
38 endif | |
39 | |
40 endfunction |