1 简介

1950s数字图像处理产生,从此学术界对它的研究连绵不绝。十多年之后,数字图像的处理被独立出来成了一门课程。图像分割技术是处理图像的一种基础技术,在图像处理领域中占了重要地位,且在图像工程、模式识别、计算机视觉等方面起着重要作用。本文正是以图像分割为研究课题,以如何能更好地图像进行省时而有效的分割为研究目的,提出了基于最大熵的脉冲耦合神经网络(PulseCoupled Neural Networks,简称PCNN)的方法。众所周知,有效的分割方法有利于理解图像的本质和后续的研究工作等,因此本文分割方法的研究是具有一定意义的。 传统的处理图像的分割问题的方法有:基于灰度级算术均值法、基于熵与直方图法、基于最大类间方差法、基于边缘的检测分割法,基于阈值的分割法,基于边界提取的分割法,基于区域的分割法,基于特定理论的分割法。同时,当然少不了产生的一些相关模型,如健壮尺度区域模型,二维经典C-V模型,尺度区域拟合模型,三维C-V模型,健壮统计三维C-V模型,几何主动轮廓模型等。本文将出基于脉冲耦合神经网络的方法。此方法对上述分割数字图像时的不足具有一定的弥补作用。用PCNN方法分割数字图像的模型中,以神经元为单元,构成二维的一层的神经元列。PCNN模型中神经元的数目一致于像素数目,每个神经元一一对应于每个像素。根据PCNN的脉冲传播特性而引起的同步脉冲现象来实现图像分割。


【图像分割】基于脉冲耦合神经网络实现图像分割附matlab代码_数字图像2 部分代码

clear all

RGB = imread('park.bmp');

figure(1);

imshow(RGB);

imwrite(RGB,'分割结果\park.jpg','jpg');

HSV = rgb2hsv(RGB); % Transform from RGB to HSV

H = HSV(:,:,1);

S = HSV(:,:,2);

V = HSV(:,:,3);

H = H+0.22;

INDEX = find(H>1);

H(INDEX) = H(INDEX) - 1;

figure(24);

imshow(H);

imwrite(H,'分割结果\park_H_revolve.jpg','jpg');

% Color quantization

QH = 16;

QS = 4;

QV = 4;

scopeH = 1 / QH;

scopeS = 1 / QS;

scopeV = 1 / QV;


siz = size(H);

M = siz(1) * siz(2);

temp = zeros(siz);

HHH = temp;

SSS = temp;

VVV = temp;

% Quantize H

for i = 1:QH

    k = find((H < i*scopeH) & (H >= (i-1)*scopeH));

    HHH(k) = i;

end

% Quantize S

for i = 1:QS

    k = find((S < i*scopeS) & (S >= (i-1)*scopeS));

    SSS(k) = i;

end

% Quantize V

for i = 1:QV

    k = find((V < i*scopeV) & (V >= (i-1)*scopeV));

    VVV(k) = i

end


% Color label

QI = temp;         % label matrix, used to statistic Ck

for i = 1:siz(1)

    for j = 1:siz(2)

        QI(i,j) = (HHH(i,j) -1)*QS*QV + (SSS(i,j) - 1)*QV + VVV(i,j);

    end

end


eQI = uint8(QI);

figure(35);

imshow(eQI);

imwrite(eQI,'分割结果\park_quantitation.jpg','jpg');

%imwrite(eQI,['Lajiao_VQofHSV','.bmp'],'bmp');


%figure(112);

%EDG2 = edge(eQI,'canny');

%imshow(EDG2);

%imwrite(EDG2,['Lajiao_VQofHSV_edg','.bmp'],'bmp');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Double PCNN

%%%link parameter%%

[row, col] = size(QI);

Va = max(max(QI));

Vb = min(min(QI));


F = QI;


vl = 1;

vt = 500;


l_deta = 1;

l_t = 0.5;

link_a = l_deta*1 / l_t;


beta = 0.012;


t_deta = 1;

t_t = 25;

threshold = t_deta*1 / t_t;


%step = 20;%optimize

step = 20;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

TEMP=zeros(row,col);

%%%%%%%%%%% to create W %%%%%%%%%%%%%%

%Ws=[0 1 0;1 1 1;0 1 0];

%%%%%%%%%%%%%%%%%%%%%

 radius=9;

 halfR = round(radius/2);

 deta = 2;

 for i = 1:radius

    for j = 1:radius

     if i==halfR & j==halfR

          K_r(halfR, halfR)=1;

          K_r2(halfR, halfR)=1;

       else

         K_r(i,j) = 1/sqrt((i-halfR)^2 + (j-halfR)^2);        

      end

    end

 end

 Ws = K_r;

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%% start program %%%%%%%%%%%%%

%%%% factor loop %%%%%

Y_threshold = TEMP;

Y_time = TEMP;

Y1 = TEMP;

Y2 = TEMP;

Y = TEMP;

Ya = TEMP;

Yb = TEMP;

Edge_image=TEMP;

L = TEMP;

U = TEMP;

T1 = TEMP + Va;

T2 = TEMP + Vb;

j = 1;


%%% determine when exit loop

accuYTrue = 1;

iterTrue = 1;

accY = TEMP;  % Accumulate total neuros of firing


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

while iterTrue

    j   

    L = link24(Y,L,Ws,link_a,vl);

    invar_fig=1;change_mark=0;k=0;

    %%%%%%%%%%%%%%%

     m=1;%% fast linking %%

     while (invar_fig==1)

          m

          mid_Y=Y;

          U=internal24(F,L,Y,beta);

          Y1 = pulse1(U, T1);

          %Y2 = pulse2(U, T2);

          Y = Y1; % + Y2;

          %Y=pulse_p(U,T,L);

          if (mid_Y==Y) 

             invar_fig=0;

          elseif m>30 & change_mark==0

             mid_Y1=mid_Y;

             mid_Y2=Y;

             change_mark=1;

          elseif change_mark==1 & k<1

             k=1;

          elseif k==1

             %if mid_Y1==mid_Y & mid_Y2==Y

                invar_fig=0;

                %else

               % change_mark=0;k=0;

               % end

          end

            L=link24(Y,L,Ws,link_a,vl);

            m=m+1;        

      end

    %%%%save threshold for fired pixels (sigle-pass)%%%%%%

    %%%%%%%statistc numbers of nurons in plusing areas %%%%%%

    index1 = find(Y1 ~= 0);%find index of element of noequal zero(index of pulsing neurons)

    q = size(index1, 1);     

    if q ~= 0     %%% statistic pulsing neurons %%%

        for yy = 1:row

            for zz = 1:col

                if(Y1(yy, zz) == 1)

                    Y_threshold(yy, zz) = round(T1(yy, zz));

                    Y_time(yy, zz) = j;

                end

            end

        end   %%% statistic end %%%

    end


    Ya = Ya + Y1;

    T1 = threshold1(T1, Ya, Va, step);  %decrement threshold(linear decay)%%%%%%%%%%

    j=j+1;

    %%%%%%%%%%%%%%%%%%%%%

    accY = accY + Y;

    index = find(accY == 0);

    size(index);

    if ans(1) == 0

        iterTrue = 0;

    end                       % Exit loop

end


figure(59);

Y_pcnn = uint8(Y_threshold)

imshow(Y_pcnn);

imwrite(Y_pcnn,'分割结果\park_pcnn_segm2.bmp','bmp');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

3 仿真结果

【图像分割】基于脉冲耦合神经网络实现图像分割附matlab代码_图像分割_02

【图像分割】基于脉冲耦合神经网络实现图像分割附matlab代码_数字图像_03

4 参考文献

[1]顾晓东, 余道衡. PCNN的原理及其应用[J]. 电路与系统学报, 2001(03):46-51.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

【图像分割】基于脉冲耦合神经网络实现图像分割附matlab代码_神经网络_04