view scripts/image/ind2rgb.m @ 595:a0cc17145462

[project @ 1994-08-09 18:42:23 by jwe]
author jwe
date Tue, 09 Aug 1994 18:42:23 +0000
parents 4e826edfbc56
children 3470f1e25a79
line wrap: on
line source

function [R G B] = ind2rgb(X,map)
#Convert an indexed image to red, green, and blue color components.
#
#[R G B] = ind2rgb(X) uses the current colormap for the conversion.
#
#[R G B] = ind2rgb(X,map) uses the specified colormap.
#
#SEE ALSO: rgb2ind, image, imshow, ind2gray, gray2ind.

  if(nargin == 1)
    map = colormap;
  endif

  [hi wi] = size(X);

  pref = do_fortran_indexing;
  do_fortran_indexing = "true";

  R = map(X(:),1);
  G = map(X(:),2);
  B = map(X(:),3);

  R = reshape(R,hi,wi);
  G = reshape(G,hi,wi);
  B = reshape(B,hi,wi);

  do_fortran_indexing = pref;

endfunction