计算机应用 | 古代文学 | 市场营销 | 生命科学 | 交通物流 | 财务管理 | 历史学 | 毕业 | 哲学 | 政治 | 财税 | 经济 | 金融 | 审计 | 法学 | 护理学 | 国际经济与贸易
计算机软件 | 新闻传播 | 电子商务 | 土木工程 | 临床医学 | 旅游管理 | 建筑学 | 文学 | 化学 | 数学 | 物理 | 地理 | 理工 | 生命 | 文化 | 企业管理 | 电子信息工程
计算机网络 | 语言文学 | 信息安全 | 工程力学 | 工商管理 | 经济管理 | 计算机 | 机电 | 材料 | 医学 | 药学 | 会计 | 硕士 | 法律 | MBA
现当代文学 | 英美文学 | 通讯工程 | 网络工程 | 行政管理 | 公共管理 | 自动化 | 艺术 | 音乐 | 舞蹈 | 美术 | 本科 | 教育 | 英语 |

基于模糊理论的图像分割算法研究(10)

2013-07-28 01:28
导读: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 % chromoso
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

上一篇:计算机多媒体技术应用分析 下一篇:没有了