function b = ind2gray(a,cm)
%IND2GRAY Convert indexed image to gray intensity image.
%	I = IND2GRAY(X,MAP) converts the image X with colormap MAP
%	to a gray scale intensity image I by removing the hue and
%	saturation information while retaining the luminance.  The
%	values in I range from 0 (black) to 1 (white). 

%	Clay M. Thompson 9-10-92
%	Copyright (c) 1992 by The MathWorks, Inc.
%	$Revision: 1.9 $  $Date: 1993/08/18 03:15:56 $

error(nargchk(2,2,nargin));

% Convert CM to NTSC coordinates
ntsc = rgb2ntsc(cm);

% Make sure A is in the range from 1 to size(cm,1)
a = max(1,min(a,size(cm,1)));

% Define B
b = zeros(size(a));
b(:) = ntsc(a,1); % Gray image is first component
