annotate scripts/image/iscolormap.m @ 20595:c1a6c31ac29a

eliminate more simple uses of error_state * ov-classdef.cc: Eliminate simple uses of error_state.
author John W. Eaton <jwe@octave.org>
date Tue, 06 Oct 2015 00:20:02 -0400
parents a3bf503652b2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
1 ## Copyright (C) 2012-2015 Carnë Draug
15513
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
2 ##
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
3 ## This file is part of Octave.
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
4 ##
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
8 ## your option) any later version.
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
9 ##
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
13 ## General Public License for more details.
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
14 ##
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
18
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
19 ## -*- texinfo -*-
15516
271f0a2d15ab iscolormap.m: Eliminate unnecessary ismatrix() test in code.
Rik <rik@octave.org>
parents: 15514
diff changeset
20 ## @deftypefn {Function File} {} iscolormap (@var{cmap})
271f0a2d15ab iscolormap.m: Eliminate unnecessary ismatrix() test in code.
Rik <rik@octave.org>
parents: 15514
diff changeset
21 ## Return true if @var{cmap} is a colormap.
15513
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
22 ##
20193
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19899
diff changeset
23 ## A colormap is a real matrix with @var{n} rows and 3 columns. Each row
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19899
diff changeset
24 ## represents a single color. The columns contain red, green, and blue
20392
a3bf503652b2 iscolormap: relax input check - specially in [0 1] range.
Carnë Draug <carandraug@octave.org>
parents: 20193
diff changeset
25 ## intensities respectively.
a3bf503652b2 iscolormap: relax input check - specially in [0 1] range.
Carnë Draug <carandraug@octave.org>
parents: 20193
diff changeset
26 ##
a3bf503652b2 iscolormap: relax input check - specially in [0 1] range.
Carnë Draug <carandraug@octave.org>
parents: 20193
diff changeset
27 ## All values in a colormap should be in the [0 1] range but this is not
a3bf503652b2 iscolormap: relax input check - specially in [0 1] range.
Carnë Draug <carandraug@octave.org>
parents: 20193
diff changeset
28 ## enforced. Each function must decide what to do for values outside this
a3bf503652b2 iscolormap: relax input check - specially in [0 1] range.
Carnë Draug <carandraug@octave.org>
parents: 20193
diff changeset
29 ## range.
a3bf503652b2 iscolormap: relax input check - specially in [0 1] range.
Carnë Draug <carandraug@octave.org>
parents: 20193
diff changeset
30 ##
15513
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
31 ## @seealso{colormap, rgbplot}
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
32 ## @end deftypefn
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
33
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
34 ## Author: Carnë Draug <carandraug+dev@gmail.com>
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
35
15516
271f0a2d15ab iscolormap.m: Eliminate unnecessary ismatrix() test in code.
Rik <rik@octave.org>
parents: 15514
diff changeset
36 function retval = iscolormap (cmap)
15513
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
37
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
38 if (nargin != 1)
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
39 print_usage;
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
40 endif
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
41
20392
a3bf503652b2 iscolormap: relax input check - specially in [0 1] range.
Carnë Draug <carandraug@octave.org>
parents: 20193
diff changeset
42 retval = (isnumeric (cmap) && isreal (cmap)
a3bf503652b2 iscolormap: relax input check - specially in [0 1] range.
Carnë Draug <carandraug@octave.org>
parents: 20193
diff changeset
43 && ndims (cmap) == 2 && columns (cmap) == 3
a3bf503652b2 iscolormap: relax input check - specially in [0 1] range.
Carnë Draug <carandraug@octave.org>
parents: 20193
diff changeset
44 && isfloat (cmap));
15513
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
45
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
46 endfunction
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
47
7a0a202fedfe iscolormap: new function for image
Carnë Draug <carandraug+dev@gmail.com>
parents:
diff changeset
48 %!assert (iscolormap (jet (64)))
15514
8d64e87c00cf iscolormap: more tests
Carnë Draug <carandraug+dev@gmail.com>
parents: 15513
diff changeset
49 %!assert (iscolormap ({0 1 0}), false)
15516
271f0a2d15ab iscolormap.m: Eliminate unnecessary ismatrix() test in code.
Rik <rik@octave.org>
parents: 15514
diff changeset
50 %!assert (iscolormap ([0 1i 0]), false)
15714
b1cd65881592 Clean up scripts in image directory.
Rik <rik@octave.org>
parents: 15516
diff changeset
51 %!assert (iscolormap (ones (3,3,3)), false)
15516
271f0a2d15ab iscolormap.m: Eliminate unnecessary ismatrix() test in code.
Rik <rik@octave.org>
parents: 15514
diff changeset
52 %!assert (iscolormap (ones (3,4)), false)