matlab adaptthresh函数源码,149行cvt2double是什么意思。
Show older comments
大家好,我最近在学习adaptthresh函数,查看了该函数的源码,其中第149行是I = cvt2double(I);,我感觉这句是数据类型转换成双精度,他的注释也差不多是这样,但是在matlab里没查到这个函数,查了很多资料也没找到cvt2double函数的解释,请问大家有知道的吗。下面是其中一段,这里是21行。完整的大家可以open adaptthresh查看。图像转换成双精度类型的函数我只知道im2double.
function T = adaptthresh(I,varargin)
args = matlab.images.internal.stringToChar(varargin);
matlab.images.internal.errorIfgpuArray(I, varargin{:});
[I,options] = parseInputs(I, args{:});
nhoodSize = options.NeighborhoodSize;
statistic = options.Statistic;
isFGBright = strcmp(options.ForegroundPolarity,'bright');
sensitivity = options.Sensitivity;
if isempty(I)
T = zeros(size(I));
return;
end
scaleFactor = sensitivityToScaleFactor(sensitivity,isFGBright);
% Convert image to double-precision. This scales integer data to [0,1].
I = cvt2double(I);
switch statistic
case 'mean'
T = localMeanThresh(I,nhoodSize,scaleFactor);
case 'median'
T = localMedianThresh(I,nhoodSize,scaleFactor);
case 'gaussian'
T = localGaussThresh(I,nhoodSize,scaleFactor);
otherwise
assert(false,'Unknown statistic string.')
end
% Restrict T to [0,1]. Saturate output values to lie in [0,1] data range
% for double-precision images.
T = max(min(T,1),0);
end
Accepted Answer
More Answers (0)
Categories
Find more on 线图 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!