
 Usage

Changes the colormap for the current figure. The generic
syntax for its use is

    colormap(map)

where map is a an array organized as  $3 \times N$ ), which
defines the RGB (Red Green Blue) coordinates for each color
in the colormap. You can also use the function with no
arguments to recover the current colormap

    map = colormap



 Internals

Assuming that the contents of the colormap function argument
c are labeled as:
 \[ c = \begin{bmatrix} r_1 &amp; g_1 &amp; b_1 \\ r_1 &amp;
g_2 &amp; b_2 \\ r_1 &amp; g_3 &amp; b_3 \\ \vdots &amp;
\vdots &amp; \vdots \end{bmatrix} \]
then these columns for the RGB coordinates of pixel in the
mapped image. Assume that the image occupies the range $
[a,b]$. Then the RGB color of each pixel depends on the
value $x$ via the following integer
 \[ k = 1 + \lfloor 256 \frac{x-a}{b-a} \rfloor, \]
so that a pixel corresponding to image value $x$ will
receive RGB color $[r_k,g_k,b_k]$. Colormaps are generally
used to pseudo color images to enhance visibility of
features, etc.


 Examples

We start by creating a smoothly varying image of a 2D
Gaussian pulse.

  --> x = linspace(-1,1,512)'*ones(1,512);
  --> y = x';
  --> Z = exp(-(x.^2+y.^2)/0.3);
  --> image(Z);

which we display with the default (grayscale) colormap here.
 colormap1.png
Next we switch to the copper colormap, and redisplay the
image.

  --> colormap(copper);
  --> image(Z);

which results in the following image.
 colormap2.png
If we capture the output of the copper command and plot it,
we obtain the following result:

  --> a = copper;
  --> plot(a);

 colormap3.png
Note that in the output that each of the color components
are linear functions of the index, with the ratio between
the red, blue and green components remaining constant as a
function of index. The result is an intensity map with a
copper tint. We can similarly construct a colormap of our
own by defining the three components seperately. For
example, suppose we take three gaussian curves, one for each
color, centered on different parts of the index space:

  --> t = linspace(0,1,256);
  --> A = [exp(-(t-1.0).^2/0.1);exp(-(t-0.5).^2/0.1);exp(-
  t.^2/0.1)]';
  --> plot(A);

 colormap4.png
The resulting image has dark bands in it near the color
transitions.

  --> image(Z);
  --> colormap(A);

 colormap5.png
These dark bands are a result of the nonuniform color
intensity, which we can correct for by renormalizing each
color to have the same norm.

  --> w = sqrt(sum(A'.^2));
  --> sA = diag(1./w)*A;
  --> plot(A);

 colormap6.png
The resulting image has no more dark bands.

  --> image(Z);
  --> colormap(A);

 colormap7.png

* FreeMat_Documentation
* Handle-Based_Graphics
* Generated on Thu Jul 25 2013 17:17:19 for FreeMat by
  doxygen_ 1.8.1.1

