Mercurial > hg > octave-nkf
annotate scripts/image/hsv.m @ 11191:01ddaedd6ad5
Reverse changeset b1f4bdc276b6. Use all lower case for "uniformoutput" option.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Thu, 04 Nov 2010 12:18:08 -0700 |
parents | 2b0cc0b6db61 |
children | 466ba499eff5 |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 1999, 2000, 2007, 2009 Kai Habel |
6788 | 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. | |
6788 | 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/>. | |
6788 | 18 |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {} hsv (@var{n}) | |
8543 | 21 ## Create color colormap. This colormap is red through yellow, green, |
22 ## cyan, blue, magenta to red. It is obtained by linearly varying the | |
23 ## hue through all possible values while keeping constant maximum | |
24 ## saturation and value and is equivalent to | |
25 ## @code{hsv2rgb ([linspace(0,1,N)', ones(N,2)])}. | |
26 ## | |
27 ## The argument @var{n} should be a scalar. If it is omitted, the | |
28 ## length of the current colormap or 64 is assumed. | |
6788 | 29 ## @seealso{colormap} |
30 ## @end deftypefn | |
31 | |
32 ## Author: Kai Habel <kai.habel@gmx.de> | |
33 | |
34 function map = hsv (number) | |
35 | |
36 if (nargin == 0) | |
37 number = rows (colormap); | |
38 elseif (nargin == 1) | |
6791 | 39 if (! isscalar (number)) |
6788 | 40 error ("hsv: argument must be a scalar"); |
41 endif | |
42 else | |
43 print_usage (); | |
44 endif | |
45 | |
46 if (number == 1) | |
47 map = [1, 0, 0]; | |
48 elseif (number > 1) | |
49 h = linspace (0, 1, number)'; | |
50 map = hsv2rgb ([h, ones(number, 1), ones(number, 1)]); | |
51 else | |
52 map = []; | |
53 endif | |
54 | |
55 endfunction | |
9751
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
8920
diff
changeset
|
56 |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
8920
diff
changeset
|
57 %!demo |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
8920
diff
changeset
|
58 %! ## Show the 'hsv' colormap as an image |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
8920
diff
changeset
|
59 %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
8920
diff
changeset
|
60 %! axis ([1, 64, 0, 1], "ticy", "xy") |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
8920
diff
changeset
|
61 %! colormap hsv |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
8920
diff
changeset
|
62 |