Mercurial > hg > octave-lyh
comparison scripts/image/rgbplot.m @ 15715:6ae93518356c
rgbplot.m. Match variable in docstring to function prototype.
* rgb2ind.m: Use Octave coding convention for parenthesis around switch arg.
* rgbplot.m: Match variable in docstring to function prototype.
Tweak docstring. Use Octave coding convention for parenthesis around
switch arg.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 02 Dec 2012 10:17:46 -0800 |
parents | b1cd65881592 |
children | e8a4b99f8bd8 |
comparison
equal
deleted
inserted
replaced
15714:b1cd65881592 | 15715:6ae93518356c |
---|---|
22 ## @deftypefnx {Function File} {} rgbplot (@var{cmap}, @var{style}) | 22 ## @deftypefnx {Function File} {} rgbplot (@var{cmap}, @var{style}) |
23 ## @deftypefnx {Function File} {@var{h} =} rgbplot (@dots{}) | 23 ## @deftypefnx {Function File} {@var{h} =} rgbplot (@dots{}) |
24 ## Plot the components of a colormap. | 24 ## Plot the components of a colormap. |
25 ## | 25 ## |
26 ## Two different @var{style}s are available for displaying the @var{cmap}: | 26 ## Two different @var{style}s are available for displaying the @var{cmap}: |
27 ## | |
27 ## @table @asis | 28 ## @table @asis |
28 ## @item profile (default) | 29 ## @item profile (default) |
29 ## Plots the RGB line profile of the colormap for each of the channels (red, | 30 ## Plot the RGB line profile of the colormap for each of the channels (red, |
30 ## green and blue) with the plot lines colored appropriately. Each line | 31 ## green and blue) with the plot lines colored appropriately. Each line |
31 ## represents the intensity of each RGB components across the colormap. | 32 ## represents the intensity of each RGB components across the colormap. |
32 ## | 33 ## |
33 ## @item composite | 34 ## @item composite |
34 ## Draws the colormap across the X axis so that the actual colors are visible | 35 ## Draw the colormap across the X-axis so that the actual index colors are |
35 ## rather than the individual color components. | 36 ## visible rather than the individual color components. |
36 ## | 37 ## |
37 ## @end table | 38 ## @end table |
38 ## | 39 ## |
39 ## Run @code{demo rgbplot} for a comparison display. | |
40 ## | |
41 ## The optional return value @var{h} is a graphics handle to the created plot. | 40 ## The optional return value @var{h} is a graphics handle to the created plot. |
42 ## | 41 ## |
42 ## Run @code{demo rgbplot} to see an example of @cdoe{rgpblot} and each style | |
43 ## option. | |
43 ## @seealso{colormap} | 44 ## @seealso{colormap} |
44 ## @end deftypefn | 45 ## @end deftypefn |
45 | 46 |
46 function retval = rgbplot (cmap, style) | 47 function h = rgbplot (cmap, style) |
47 | 48 |
48 if (nargin < 1 || nargin > 2) | 49 if (nargin < 1 || nargin > 2) |
49 print_usage (); | 50 print_usage (); |
50 endif | 51 endif |
51 | 52 |
53 error ("rgbplot: CMAP must be a valid colormap"); | 54 error ("rgbplot: CMAP must be a valid colormap"); |
54 elseif (! ischar (style)) | 55 elseif (! ischar (style)) |
55 error ("rgbplot: STYLE must be a string"); | 56 error ("rgbplot: STYLE must be a string"); |
56 endif | 57 endif |
57 | 58 |
58 switch tolower (style) | 59 switch (tolower (style)) |
59 case "profile" | 60 case "profile" |
60 h = plot (cmap(:,1),"r", cmap(:,2),"g", cmap(:,3),"b"); | 61 htmp = plot (cmap(:,1),"r", cmap(:,2),"g", cmap(:,3),"b"); |
61 set (gca, 'ytick', 0:0.1:1); | 62 set (gca, 'ytick', 0:0.1:1); |
62 case "composite" | 63 case "composite" |
63 h = image (1:rows(cmap)); | 64 htmp = image (1:rows(cmap)); |
64 set (gca, 'ytick', []); | 65 set (gca, 'ytick', []); |
65 colormap (cmap); | 66 colormap (cmap); |
66 otherwise | 67 otherwise |
67 error ("rgbplot: unknown style `%s'", style); | 68 error ("rgbplot: unknown style `%s'", style); |
68 endswitch | 69 endswitch |
72 h = htmp; | 73 h = htmp; |
73 endif | 74 endif |
74 | 75 |
75 endfunction | 76 endfunction |
76 | 77 |
78 | |
77 %!demo | 79 %!demo |
78 %! clf; | 80 %! clf; |
79 %! subplot (1, 2, 1); | 81 %! subplot (1, 2, 1); |
80 %! rgbplot (ocean, "profile"); | 82 %! rgbplot (ocean, "profile"); |
81 %! subplot (1, 2, 2) | 83 %! subplot (1, 2, 2); |
82 %! rgbplot (ocean, "composite"); | 84 %! rgbplot (ocean, "composite"); |
83 | 85 |
84 %% Test input validation | 86 %% Test input validation |
85 %!error rgbplot () | 87 %!error rgbplot () |
86 %!error rgbplot (1,2) | 88 %!error rgbplot (1,2) |