gnrtlclinvst.m

来自「ostu图像分割阈值算法,对Ostu图像分割最优阈值进行优化处理」· M 代码 · 共 26 行

M
26
字号
function TheInvst=GnrtLclInvst(TheSltn,TheInvstVar, TheSltnMaxLmt, TheSltnMinLmt)

[TheSltnDmsnNmbr1,TheSltnDmsnNmbr2]=size(TheSltn);

for i=1:TheSltnDmsnNmbr2
    u=rand;
    z=TheInvstVar*(sqrt(2*log(1/(1-u))));    %正态分布
    TheInvst(i)=TheSltn(i)+z*cos(2*pi*u);
end

if ChckSltn(TheInvst, TheSltnMaxLmt, TheSltnMinLmt) == 0%范围检测
    for i = 1 : TheSltnDmsnNmbr2
        if TheInvst(i) > TheSltnMaxLmt
            TheInvst(i) = 2 * TheSltnMaxLmt - TheInvst(i);
        end
        
        if TheInvst(i) < TheSltnMinLmt
            TheInvst(i) = 2 * TheSltnMinLmt - TheInvst(i);
        end        
    end       
end




⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?