# HG changeset patch # User carandraug # Date 1354467452 0 # Node ID 442cb00e506b35c754e92a8fe706258d666f2afd # Parent 2deb6b24d2939c36c6de0cd353bfb1de7a68cde9 rgbplot: add new style option to also display composite colormap diff -r 2deb6b24d293 -r 442cb00e506b main/image/NEWS --- a/main/image/NEWS Fri Nov 30 20:13:45 2012 +0000 +++ b/main/image/NEWS Sun Dec 02 16:57:32 2012 +0000 @@ -15,6 +15,9 @@ one vector in the column direction and another vector in the row direction, has been removed. Please use conv2 for such cases. + ** The function `rgbplot' accepts a style option which alows for a composite + display of a colormap. + Summary of important user-visible changes for image 2.0.0: ------------------------------------------------------------------- diff -r 2deb6b24d293 -r 442cb00e506b main/image/inst/rgbplot.m --- a/main/image/inst/rgbplot.m Fri Nov 30 20:13:45 2012 +0000 +++ b/main/image/inst/rgbplot.m Sun Dec 02 16:57:32 2012 +0000 @@ -1,4 +1,5 @@ ## Copyright (C) 2012 Rik Wehbring +## Copyright (C) 2012 Carnë Draug ## ## This file is part of Octave. ## @@ -18,30 +19,53 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} rgbplot (@var{cmap}) +## @deftypefnx {Function File} {} rgbplot (@var{cmap}, @var{style}) ## @deftypefnx {Function File} {@var{h} =} rgbplot (@dots{}) ## Plot the components of a colormap. ## -## The first column is plotted in red, the second column in green, and -## the third column in blue. The values are between 0 and 1 and represent -## the intensity of the RGB components in the given indexed color. +## Two different @var{style}s are available for displaying the @var{cmap}: +## @table @asis +## @item profile (default) +## Plots the RGB line profile of the colormap for each of the channels (red, +## green and blue) with the plot lines colored appropriately. Each line +## represents the intensity of each RGB components across the colormap. +## +## @item composite +## Draws the colormap across the X axis so that the actual colors are visible +## rather than the individual color components. +## +## @end table +## +## Run @code{demo rgbplot} for a comparison display. ## ## The optional return value @var{h} is a graphics handle to the created plot. ## ## @seealso{colormap} ## @end deftypefn -function retval = rgbplot (cmap) +function retval = rgbplot (cmap, style) - if (nargin != 1) + if (nargin < 1 || nargin > 2) print_usage (); endif if (! iscolormap (cmap)) error ("rgbplot: CMAP must be a colormap"); + elseif (! ischar (style)) + error ("rgbplot: STYLE must be a string"); endif - h = plot (cmap(:,1),"r", cmap(:,2),"g", cmap(:,3),"b"); - set (gca, 'ytick', 0:0.1:1); + switch tolower (style) + case "profile" + h = plot (cmap(:,1),"r", cmap(:,2),"g", cmap(:,3),"b"); + set (gca, 'ytick', 0:0.1:1); + case "composite" + h = image (1:rows(cmap)); + set (gca, 'ytick', []); + colormap (cmap); + otherwise + error ("rgbplot: unknown style `%s'", style); + endswitch xlabel ("color index"); if (nargout > 0) @@ -50,10 +74,12 @@ endfunction - %!demo %! clf; -%! rgbplot (ocean); +%! subplot (1, 2, 1); +%! rgbplot (ocean, "profile"); +%! subplot (1, 2, 2) +%! rgbplot (ocean, "composite"); %%test input validation %!error rgbplot () diff -r 2deb6b24d293 -r 442cb00e506b main/image/inst/wavelength2rgb.m --- a/main/image/inst/wavelength2rgb.m Fri Nov 30 20:13:45 2012 +0000 +++ b/main/image/inst/wavelength2rgb.m Sun Dec 02 16:57:32 2012 +0000 @@ -170,6 +170,7 @@ %!demo %! -%! RGB = wavelength2rgb (350:800); # RGB values for wavelengths between 350 and 800 nm -%! RGB = RGB .* ones (300, 1, 1); # make it 300 rows for display -%! imshow (RGB) +%! ##draw RGB values for wavelengths between 350 and 800 nm +%! RGB = wavelength2rgb (350:800); +%! rgbplot (RGB, "composite"); +%! axis off;