ind2gray.m
来自「有关matlab的电子书籍有一定的帮助希望有用」· M 代码 · 共 38 行
M
38 行
function b = ind2gray(a,cm)
%IND2GRAY Convert indexed image to intensity image.
% I = IND2GRAY(X,MAP) converts the image X with colormap MAP
% to an intensity image I. IND2GRAY removes the hue and
% saturation information while retaining the luminance.
%
% Class Support
% -------------
% X can be of class uint8 or double. I is of class double.
%
% Example
% -------
% load trees
% I = ind2gray(X,map);
% imshow(X,map), figure, imshow(I)
%
% See also GRAY2IND, IMSHOW, RGB2NTSC.
% Clay M. Thompson 9-10-92
% Copyright 1993-1998 The MathWorks, Inc. All Rights Reserved.
% $Revision: 5.6 $ $Date: 1997/11/24 15:35:39 $
if isa(a, 'uint8')
a = double(a)+1; % Switch to one based indexing
end
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
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?