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