该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
程序如下:
clear all
clc
tic
popsize=15;
lanti=10;
maxgen=50;
cross_rate=0.4;
mutation_rate=0.1;
a0=0.7;
zpopsize=5;
bestf=0;
nf=0;
number=0;
I=imread('C:\Users\Yu\Pictures\feiji.jpg');
if numel(I)>2
I=rgb2gray(I);
end
[m,n]=size(I);
p=imhist(I);
p=p';
p=p/(m*n);
figure(1);
subplot(1,2,1);
imshow(I);
title('yuantu');
hold on
pop=2*rand(popsize,lanti)-1;
pop=hardlim(pop);
for gen=1:maxgen
[fitness,yuzhi,number]=fitnessty(pop,lanti,I,popsize,m,n,number);
if max(fitness)>bestf
bestf=max(fitness);
nf=0;
for i&