pp.m
来自「将PSO和LBG结合在一步迭代过程中」· M 代码 · 共 42 行
M
42 行
% =====================================================================
% PP algorithm
% Start Date: 15/07/2006
% Last Changed: 21/08/2006
% Usage: Before runing the program, make sure experimental image exist
%
% Specification: The algorithm, proposed by Ji and Liao in 2006, incorporating
% both PSO algorithm and LBG to one iteration and using
% particle-pair to explore in the problem space
%
% Copyright (c) Ji and Liao in 2006
% All rights Reserved
%==========================================================================
warning off MATLAB:divideByZero
clear all;
psnr1=0;
k=2;
particle=[];
pbest_value=[];
t=[];
gbest_value_smallpop=[];
for i=1:k
[particlenext,pbestnext,t1,gbest_value]=PSOLBG1;
particle=[particle;particlenext];
pbest_value=[pbest_value;pbestnext];
gbest_value_smallpop=[gbest_value_smallpop;gbest_value];
t=[t,t1];
end
[gbest,psnr1,t2,gbest_value_pop3,tempz_cluster]=PSOLBG2(particle,pbest_value);
t=[t,t2];
timeconsumed=sum(t)/60 %time used in minute
psnr1 % the psnr value of last iteration
% evaluate the distortion below
GenTrainingVector;
num_cluster=256;
num_trainingvector=4096;
for j=1:num_trainingvector
[C(j),I(j)]=min(sum((repmat(trainingvector(j,:),num_cluster,1)-tempz_cluster).^2,2));
end
Distortion=sum(C)/4096
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?