Mercurial > octave-nkf
annotate scripts/image/colormap.m @ 14260:1f911333ed3d
doc: Update docstrings for functions in image/ directory
* aspell-octave.en.pws, brighten.m, colormap.m, contrast.m, flag.m, gmap40.m
gray.m, gray2ind.m, hsv2rgb.m, image.m, ind2gray.m, ind2rgb.m, ntsc2rgb.m,
ocean.m, rgb2hsv.m, rgb2ind.m, rgb2ntsc.m: Update docstrings.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Tue, 24 Jan 2012 09:51:48 -0800 |
parents | 8b220af26cfb |
children | b9c02ee24de1 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1 ## Copyright (C) 1994-2012 John W. Eaton |
2313 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
1024 | 18 |
3381 | 19 ## -*- texinfo -*- |
14246
8b220af26cfb
doc: Update docstring for colormap()
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
20 ## @deftypefn {Function File} {@var{cmap} =} colormap () |
8b220af26cfb
doc: Update docstring for colormap()
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
21 ## @deftypefnx {Function File} {@var{cmap} =} colormap (@var{map}) |
8b220af26cfb
doc: Update docstring for colormap()
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
22 ## @deftypefnx {Function File} {@var{cmap} =} colormap ("default") |
14260
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14246
diff
changeset
|
23 ## Query or set the current colormap. |
3426 | 24 ## |
3373 | 25 ## @code{colormap (@var{map})} sets the current colormap to @var{map}. The |
14260
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14246
diff
changeset
|
26 ## colormap should be an @var{n} row by 3 column matrix. The columns |
3373 | 27 ## contain red, green, and blue intensities respectively. All entries |
14260
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14246
diff
changeset
|
28 ## must be between 0 and 1 inclusive. The new colormap is returned. |
3426 | 29 ## |
6895 | 30 ## @code{colormap ("default")} restores the default colormap (the |
31 ## @code{jet} map with 64 entries). The default colormap is returned. | |
3426 | 32 ## |
3373 | 33 ## With no arguments, @code{colormap} returns the current color map. |
6895 | 34 ## @seealso{jet} |
3373 | 35 ## @end deftypefn |
559 | 36 |
3202 | 37 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
2312 | 38 ## Created: July 1994 |
39 ## Adapted-By: jwe | |
904 | 40 |
2312 | 41 function cmap = colormap (map) |
559 | 42 |
1062 | 43 if (nargin > 1) |
5923 | 44 print_usage (); |
1062 | 45 endif |
559 | 46 |
1024 | 47 if (nargin == 1) |
3238 | 48 |
5443 | 49 if (ischar (map)) |
1024 | 50 if (strcmp (map, "default")) |
6895 | 51 map = jet (64); |
559 | 52 else |
6257 | 53 map = feval (map); |
559 | 54 endif |
3238 | 55 endif |
56 | |
57 if (! isempty (map)) | |
58 if (columns (map) != 3) | |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
59 error ("colormap: MAP must have 3 columns: [R,G,B]"); |
3238 | 60 endif |
61 if (min (min (map)) < 0 || max (max (map)) > 1) | |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
62 error ("colormap: MAP must have values in [0,1]"); |
3238 | 63 endif |
2303 | 64 ## Set the new color map |
6257 | 65 set (gcf (), "colormap", map); |
559 | 66 endif |
3238 | 67 |
559 | 68 endif |
69 | |
2303 | 70 ## Return current color map. |
7108 | 71 if (nargout > 0 || (nargout == 0 && nargin == 0)) |
6762 | 72 cmap = get (gcf (), "colormap"); |
73 endif | |
1024 | 74 |
559 | 75 endfunction |