• 大小: 0.33M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-04-27
  • 语言: Matlab
  • 标签: Modified  image  MATLAB  SFLA  

资源简介

medical image thresholding using modified SFLA

资源截图

代码片段和文件信息

function main()
clear all
close all
clc
global chrom oldpop fitness lchrom  popsize cross_rate mutation_rate yuzhisum
global maxgen  m n fit gen yuzhi A B C oldpop1 popsize1 b b1 fitness1 yuzhi1
A=imread(‘D:/anis/1/bld.png‘);     
A=imresize(A10);
B=rgb2gray(A);         
C=imresize(B0.1);    
lchrom=8;              
popsize=10;  
F=lchrom*popsize;
cross_rate=0.7;        
mutation_rate=0.4;     
maxgen=20;            
[mn]=size(C);
imshow(C);
initpop;
imshow(oldpop);
 for gen=1:maxgen
   fitness_order()   
 end
 result=floor(yuzhi(1gen))
 C=imresize(B0.3);
imshow(A);
title(‘原始道路图像‘)
   figure;
subplot(121)
imshow(C);
title(‘原始道路的灰度图‘)
[mn]=size(C);

for i=1:m
    for j=1:n
        if C(ij)<=result
            C(ij)=255;
        else
            C(ij)=0;
        end
    end
end
se1=strel(‘square‘3);               
SI1=imerode(Cse1);
BW=C-SI1;
subplot(122)
imshow(BW);
title(‘阈值分割后的道路图‘);

function initpop()
global lchrom oldpop popsize chrom C
for i=1:popsize
    chrom=rand(1lchrom);
    for j=1:lchrom
        if chrom(1j)<0.5
            chrom(1j)=0;
       else 
           chrom(1j)=1;
        end
    end
    oldpop(i1:lchrom)=chrom;    
end

function fitness_order()
global lchrom oldpop fitness popsize chrom fit gen C m n F fitness1 yuzhisum
global lowsum higsum u1 u2 yuzhi gen oldpop1 popsize1 b1 b yuzhi1 

for i=1:popsize
    lowsum=0;
    higsum=0;
    lownum=0;
    hignum=0;
    chrom=oldpop(i:)
    c=0;
    for j=1:lchrom
        c=c+chrom(1j)*(2^(lchrom-j));
    end
    b(1i)=c*255/(2^lchrom-1);          
    for x=1:m
        for y=1:n
            if C(xy)<=b(1i)
                lowsum=lowsum+double(C(xy));
                lownum=lownum+1; 
            else
                higsum=higsum+double(C(xy));
                hignum=hignum+1; 
            end
        end
    end
    if lownum~=0
        u1=lowsum/lownum; 
    else
        u1=0;
    end
    if hignum~=0
        u2=higsum/hignum;
    else
        u2=0;
    end   
    fitness(1i)=lownum*hignum*(u1-u2)^2 
end

    %sort the F frogs in order of decreasing performance value
    [fitnessSortindex]=sort(fitness‘descend‘)
   for i=1:popsize   
        X(i:)=oldpop(index(i):)
   end
   pb=X(1:);
   pw=X(popsize:);
fitness(1index(1))
ipwfitness=0;

while ipwfitness    low=0;
    hig=0;
    lown=0;
    hign=0;
    c1=0;
    
   s1=rand(18).*(pb-pw);
   ipw=pw+s1
   
   for i=1:lchrom
       if ipw(1i)<0.5
           ipw(1i)=0;
       else 
           ipw(1i)=1;
       end
   end
   
    for j=1:lchrom
        c1=c1+ipw(1j)*(2^(lchrom-j));
    end
    b1(1i)=c1*255/(2^lchrom-1);          
    for x=1:m
        for y=1:n
            if C(xy)<=b1(1i)
                low=low+double(C(xy));
                lown=lown+1; 
            else
                hig=hig+double(C(xy));
                hign

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      43756  2012-01-06 10:29  bld.PNG

     文件      51779  2012-01-12 22:18  medi.jpg

     文件       3711  2012-01-12 17:24  Untitled.asv

     文件       3698  2012-01-13 23:16  Untitled.m

     文件     251936  2000-01-06 22:43  1.JPG

----------- ---------  ---------- -----  ----

               354880                    5


评论

共有 条评论