📄 initialise.asv
字号:
function [pop]=initialise(popsize,stringlength,a,b)
% popsize=20;stringlength=8;
pop=zeros(popsize,stringlength+2);
i=1;
% for i=1:popsize
while i<=popsize
pop1=round(rand(1,stringlength));
sum=0;
for k=1:stringlength
sum=sum+pop1(k)*2^(k-1);
end
x=sum;%解码
% A=imread('pout.tif');
% load woman;
% A=imread('blood1.tif');
% my=imread('mysaturn.tif');
% A=wiener2(my,[5 5]);
% A=imnoise(a,'gaussian',0,0.05);
% A=imread('kids.tif');
a=imread('mytu.tif');
count=imhist(A);
[m,n]=size(A);
N=m*n;
L=256;
count=count/N;
u=0;
for j=1:L
u=u+count(j)*j;
end
w=0;ua=0;
for j=1:x
w=w+count(j);
ua=ua+count(j)*j;
end
if (w~=0)&(w~=1)
eval1=(u*w-ua)^2/(w*(1-w));
pop(i,1:stringlength)=pop1;
pop(i,stringlength+1)=x;
pop(i,stringlength+2)=eval1;
i=i+1;
else
i=i;
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -