clc;
clear;
close all;
warning off;
addpath(genpath(pwd));
load PAN.mat; %% loading the MS image
load MS.mat; %% Loading the PAN image
MSWV_db = double(MS);
PANWV_db = double(PAN);
MS_ORG = double(MS);
MSWV_US = imresize(MSWV_db, 1/4, 'bicubic');
MSWV_US = imresize(MSWV_US, 4, 'bicubic');
MSWV_DG = MSWV_US;
PANWV_DS = imresize(PANWV_db, 1/4, 'bicubic');
PANWV_US = imresize(PANWV_DS, 4, 'bicubic');
R = MSWV_US(:,:,1);
G = MSWV_US(:,:,2);
B = MSWV_US(:,:,3);
NIR = MSWV_US(:,:,4);
for i=1:size(MSWV_US,3)
bandCoeffs(i) = max(max(MSWV_US(:,:,i)));
MSWV_US(:,:,i) = MSWV_US(:,:,i)/bandCoeffs(i);
end
P = PANWV_DS;
panCoeff = max(max(P));
P = P/panCoeff;
CostFunction=@(x) ERGAS_Index(x); % Cost Function
nVar = 4; % Number of Decision Variables
VarSize = [1 nVar]; % Size of Decision Variables Matrix
VarMin = 0; % Lower Bound of Variables
VarMax = 1; % Upper Bound of Variables
MaxIt = 25; % Maximum Number of Iterations
nPop = 10; % Population Size (Swarm Size)
phi1 = 2.05;
phi2 = 2.05;
phi = phi1+phi2;
chi = 2/(phi-2+sqrt(phi^2-4*phi));
w = chi; % Inertia Weight
wdamp = 1; % Inertia Weight Damping Ratio
c1 = chi*phi1; % Personal Learning Coefficient
c2 = chi*phi2; % Global Learning Coefficient
% Velocity Limits
VelMax = 0.1*(VarMax-VarMin);
VelMin = -VelMax;
empty_particle.Position = [];
empty_particle.Cost = [];
empty_particle.Velocity = [];
empty_particle.Best.Position = [];
empty_particle.Best.Cost = [];
particle = repmat(empty_particle,nPop,1);
GlobalBest.Cost = 0;
for i = 1:nPop
% Initialize Position
particle(i).Position = unifrnd(VarMin,VarMax,VarSize);
% Initialize Velocity
particle(i).Velocity = zeros(VarSize);
% Evaluation
particle(i).Cost = CostFunction(particle(i).Position);
% Update Personal Best
particle(i).Best.Position = particle(i).Position;
particle(i).Best.Cost = particle(i).Cost;
% Update Global Best
if particle(i).Best.Cost > GlobalBest.Cost
GlobalBest = particle(i).Best;
end
end
BestCost = zeros(MaxIt,1);
for it = 1:MaxIt
% figure
for i=1:nPop
% Update Velocity
particle(i).Velocity = w*particle(i).Velocity ...
+c1*rand(VarSize).*(particle(i).Best.Position-particle(i).Position) ...
+c2*rand(VarSize).*(GlobalBest.Position-particle(i).Position);
% Apply Velocity Limits
particle(i).Velocity = max(particle(i).Velocity,VelMin);
particle(i).Velocity = min(particle(i).Velocity,VelMax);
% Update Position
particle(i).Position = particle(i).Position + particle(i).Velocity;
% Velocity Mirror Effect
IsOutside=(particle(i).Position<VarMin | particle(i).Position>VarMax);
particle(i).Velocity(IsOutside)=-particle(i).Velocity(IsOutside);
% Apply Position Limits
particle(i).Position = max(particle(i).Position,VarMin);
particle(i).Position = min(particle(i).Position,VarMax);
particle(i).Cost = CostFunction(particle(i).Position);
% Update Personal Best
if particle(i).Cost<particle(i).Best.Cost
particle(i).Best.Position = particle(i).Position;
particle(i).Best.Cost = particle(i).Cost;
% Update Global Best
if particle(i).Best.Cost < GlobalBest.Cost
GlobalBest = particle(i).Best;
end
end
end
BestCost(it) = GlobalBest.Cost;
disp(['Iteration ' num2str(it) ': Best Cost = ' num2str(BestCost(it))]);
w = w*wdamp;
end
BestSol = GlobalBest;
lamda = 10^-9;
eps = 10^-10;
% PAN weight in edge detector
F_P = expEdge(P, lamda,eps);
% MS weight in edge detector
Red_W = max(max(R)); % Red component
R = R/Red_W;
F_R = expEdge(R, lamda, eps);
Green_W = max(max(G)); % Green component
G = G/Green_W;
F_G = expEdge(G, lamda,eps);
Blue_W = max(max(B)); % Blue component
B = B/Blue_W;
F_B = expEdge(B, lamda,eps);
NIR_W=max(max(NIR)); % NIR component
NIR=NIR/NIR_W;
F_NIR = expEdge(NIR, lamda,eps);
W = impGradDes(MSWV_US,P); % Optimal weights for spectral bands
I = W(1)*MSWV_US(:,:,1) + W(2)*MSWV_US(:,:,2) + W(3)*MSWV_US(:,:,3) + W(4)*MSWV_US(:,:,4);
P = (P-mean(P(:)))*std(I(:))/std(P(:)) + mean(I(:)); % Histogram matching
W_R = 4*R./(R + B + G + NIR);
W_B = 4*B./(R + B + G + NIR);
W_G = 4*G./(R + B + G + NIR);
W_NIR = 4*NIR./(R + B + G + NIR);
F_PSO(:,:,1) = MSWV_US(:,:,1) + W_R.*(BestSol.Position(1)*F_P + (1-BestSol.Position(1))*F_R).*(P-I);
F_PSO(:,:,2) = MSWV_US(:,:,2) + W_G.*(BestSol.Position(2)*F_P + (1-BestSol.Position(2))*F_G).*(P-I);
F_PSO(:,:,3) = MSWV_US(:,:,3) + W_B.*(BestSol.Position(3)*F_P + (1-BestSol.Position(3))*F_B).*(P-I);
F_PSO(:,:,4) = MSWV_US(:,:,4) + W_NIR.*(BestSol.Position(4)*F_P + (1-BestSol.Position(4))*F_NIR).*(P-I);
for i = 1:size(MS_ORG, 3)
F_PSO(:,:,i) = F_PSO(:,:,i)*bandCoeffs(i);
end
figure, imshow(uint8(MSWV_DG(:,:,1:3)),'border','tight');
figure, imshow(uint8(PANWV_DS),'border','tight');
figure, imshow(uint8(F_PSO(:,:,1:3)),'border','tight');
addpath Objective_Evaluation
Methods = {'PSO'};
ERGAS = ERGAS(MS_ORG,F_PSO, 4);
SAM = SAM(MS_ORG,F_PSO);
RASE = RASE(MS_ORG,F_PSO);
RMSE = RMSE(MS_ORG,F_PSO);
UIQI = uqi(MS_ORG,F_PSO);
CC = CC(MS_ORG,F_PSO);
T = table(ERGAS, SAM, RASE, RMSE, UIQI, CC, 'RowNames', Methods)
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
1.版本:matlab2021a,包含仿真操作录像,操作录像使用windows media player播放。 2.领域:多光谱图像融合 3.内容:基于PSO优化的多光谱图像融合算法matlab仿真,将彩色模糊图像和灰色清晰图像进行融合处理,得到高清彩色图像。 4.注意事项:注意MATLAB左侧当前文件夹路径,必须是程序所在文件夹位置,具体可以参考视频录。
资源推荐
资源详情
资源评论
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/AVI.png)
共 28 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/6534a49295004b5796c3956cb3f87481_ccsss22.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
fpga和matlab
- 粉丝: 16w+
- 资源: 2596
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)