您现在的位置:首页 >> ★免费资源 >> 源码下载 >> 内容

MATLAB代做-python代做-PCNN算法的图像分割

时间:2018-12-30 0:50:29 点击:

  核心提示:MATLAB代做-python代做-PCNN算法的图像分割...
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');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

联系:highspeedlogic

QQ :1224848052

微信:HuangL1121

邮箱:1224848052@qq.com

网站:http://www.mat7lab.com/

网站:http://www.hslogic.com/

微信扫一扫:

Tags:PCNN算法 
作者:PCNN算法 来源:网络
  • 您是如何找到本站的?
  • 百度搜索
  • Google搜索
  • 查阅资料过程中
  • 论坛发现
  • 百度贴吧发现
  • 朋友介绍
本站最新成功开发工程项目案例
相关文章
  • 没有相关文章
相关评论
发表我的评论
  • 大名:
  • 内容:
  • matlab代做|matlab专业代做|matlab淘宝代做(www.hslogic.com) © 2019 版权所有 All Rights Reserved.
  • Email:highspeed_logic@163.com 站长QQ: 1224848052

    专业代做/代写/承接、MATLAB、SIMULINK、FPGA项目、博士/硕士/本科毕业设计、课题设计、论文,毕业论文,Coursework、Eassy、Assignment