im2double.m
来自「有关matlab的电子书籍有一定的帮助希望有用」· M 代码 · 共 49 行
M
49 行
function d = im2double(img, typestr)
%IM2DOUBLE Convert image to double precision.
% IM2DOUBLE takes an image as input, and returns an image of
% class double. If the input image is of class double, the
% output image is identical to it. If the input image is of
% class uint8, im2double returns the equivalent image of class
% double, rescaling or offsetting the data as necessary.
%
% I2 = IM2DOUBLE(I1) converts the intensity image I1 to double
% precision, rescaling the data if necessary.
%
% RGB2 = IM2DOUBLE(RGB1) converts the truecolor image RGB1 to
% double precision, rescaling the data if necessary.
%
% BW2 = IM2DOUBLE(BW1) converts the binary image BW1 to double
% precision.
%
% X2 = IM2DOUBLE(X1,'indexed') converts the indexed image X1 to
% double precision, offsetting the data if necessary.
%
% See also DOUBLE, IM2UINT8, UINT8.
% Chris Griffin 6-9-97
% Copyright 1993-1998 The MathWorks, Inc. All Rights Reserved.
% $Revision: 1.5 $ $Date: 1997/11/24 15:35:13 $
if isa(img, 'double')
d = img;
elseif isa(img, 'uint8')
if nargin==1
if islogical(img) % uint8 binary image
d = double(img);
else % uint8 intensity image
d = double(img)/255;
end
elseif nargin==2
if ~ischar(typestr) | (typestr(1) ~= 'i')
error('Invalid input arguments');
else
d = double(img)+1;
end
else
error('Invalid input arguments.');
end
else
error('Unsupported input class.');
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?