基于模糊理论的图像分割算法研究(10)
作者:佚名; 更新时间:2014-12-05
s:

%

%           Chrom    - A matrix containing the random valued chromosomes

%                      row wise.

%

%           Lind -  A scalar containing the length of the chromosome.

%

%           BaseV     - A row vector containing the base of the

%                     chromosome loci.

% Author: Andrew Chipperfield

% Date:   19-Jan-94

function [Chrom, Lind, BaseV] = crtbp(Nind, Lind, Base)

nargs = nargin ;

% Check parameter consistency

if nargs >= 1, [mN, nN] = size(Nind) ; end

if nargs >= 2, [mL, nL] = size(Lind) ; end

if nargs == 3, [mB, nB] = size(Base) ; end

if nN == 2

   if (nargs == 1)

      Lind = Nind(2) ; Nind = Nind(1) ; BaseV = crtbase(Lind) ;

   elseif (nargs == 2 & nL == 1)

      BaseV = crtbase(Nind(2),Lind) ; Lind = Nind(2) ; Nind = Nind(1) ;

   elseif (nargs == 2 & nL > 1)

      if Lind ~= length(Lind), error('Lind and Base disagree'); end

      BaseV = Lind ; Lind = Nind(2) ; Nind = Nind(1) ;

   end

elseif nN == 1

   if nargs == 2

      if nL == 1, BaseV = crtbase(Lind) ;

      else, BaseV = Lind ; Lind = nL ; end

   elseif nargs == 3

      if nB == 1, BaseV = crtbase(Lind,Base) ;

      elseif nB ~= Lind, error('Lind and Base disagree') ;

      else BaseV = Base ; end

   end

else

   error('Input parameters inconsistent') ;

end

% Create a structure of random chromosomes in row wise order, dimensions

% Nind by Lind. The base of each chromosomes loci is given by the value

% of the corresponding element of the row vector base.

Chrom = floor(rand(Nind,Lind).*BaseV(ones(Nind,1),:)) ;

% End of file

附录 三

Bs2rv函数源代码:  (由谢菲尔德大学Andrew Chipperfield编写)

% BS2RV.m - Binary string to real vector

%

% This function decodes binary chromosomes into vectors of reals. The

% chromosomes are seen as the concatenation of binary strings of given

% length, and decoded into real numbers in a specified interval using

% either standard binary or Gray decoding.

%

% Syntax:       Phen = bs2rv(Chrom,FieldD)

%

% Input parameters:

%

%               Chrom    - Matrix containing the chromosomes of the current

%                          population. Each line corresponds to one

%                          individual's concatenated binary string

%                     representation. Leftmost bits are MSb and

%                     rightmost are LSb.

%

%               FieldD   - Matrix describing the length and how to decode

%                     each substring in the chromosome. It has the

%                     following structure:

%

%                         [len;        (num)

%                         lb;         (num)

%                         ub;        (num)

%                         code;            (0=binary     | 1=gray)

%                         scale;           (0=arithmetic | 1=logarithmic)

%                         lbin;             (0=excluded   | 1=included)

%                         ubin];           (0=excluded   | 1=included)

%

%                     where

%                         len   - row vector containing the length of

%                                each substring in Chrom. sum(len)

%                                should equal the individual length.

%                         lb,

%                         ub    - Lower and upper bounds for each

%                                variable.

%                         code  - binary row vector indicating how each

%                                substring is to be decoded.

%                         scale - binary row vector indicating where to

%                                use arithmetic and/or logarithmic

%                                scaling.

%                         lbin,

%                         ubin  - binary row vectors indicating whether

%                                or not to include each bound in the

%                                representation range

%

% Output parameter:

%

%               Phen     - Real matrix containing the population phenotypes.

%

% Author: Carlos Fonseca,   Updated: Andrew Chipperfield

% Date: 08/06/93,         Date: 26-Jan-94

function Phen = bs2rv(Chrom,FieldD)

% Identify the population size (Nind)

%      and the chromosome length (Lind)

[Nind,Lind] = size(Chrom);

% Identify the number of decision variables (Nvar)

[seven,Nvar] = size(FieldD);

if seven ~= 7

       error('FieldD must have 7 rows.');

end

% Get substring properties

len = FieldD(1,:);

lb = FieldD(2,:);

ub = FieldD(3,:);

code = ~(~FieldD(4,:));

scale = ~(~FieldD(5,:));

lin = ~(~FieldD(6,:));

uin = ~(~FieldD(7,:));

% Check substring properties for consistency

if sum(len) ~= Lind,

       error('Data in FieldD must agree with chromosome length');

end

if ~all(lb(scale).*ub(scale)>0)

       error('Log-scaled variables must not include 0 in their range');

end

% Decode chromosomes

Phen = zeros(Nind,Nvar);

lf = cumsum(len);

li = cumsum([1 len]);

Prec = .5 .^ len;

logsgn = sign(lb

核心期刊快速发表
Copyright@2000-2030 论文期刊网 Corporation All Rights Reserved.
《中华人民共和国信息产业部》备案号:ICP备07016076号;《公安部》备案号:33010402003207
本网站专业、正规提供职称论文发表和写作指导服务,并收录了海量免费论文和数百个经国家新闻出版总署审批过的具有国内统一CN刊号与国际标准ISSN刊号的合作期刊,供诸位正确选择和阅读参考,免费论文版权归原作者所有,谨防侵权。联系邮箱:256081@163.com