【图像融合】基于matlab图像融合评价指标【含Matlab源码 789期】

✅博主简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,Matlab项目合作可私信。
🍎个人主页:海神之光
🏆代码获取方式:
海神之光Matlab王者学习之路—代码获取方式
⛳️座右铭:行百里者,半于九十。

更多Matlab仿真内容点击👇
Matlab图像处理(进阶版)
路径规划(Matlab)
神经网络预测与分类(Matlab)
优化求解(Matlab)
语音处理(Matlab)
信号处理(Matlab)
车间调度(Matlab)

⛄一、评价指标分类

对于融合图像,其评价指标可以按如下划分为三类
1 基于无参考的统计特征
2 基于有参考的理想(目标)图像
3 基于有参考的源图像

⛄二 、基于无参考的统计特征

2.1 平均梯度算法

function outval=ftidu(img) 
    A=double(img); 
    [r,c]=size(A);    
    [dzdx,dzdy]=gradient(A); 
        %分别求X的梯度和Y的梯度
        s=sqrt((dzdx.^2+dzdy.^2)./2); 
        g=sum(sum(s))/(r*c); 
    outval=mean(g); 
end

1.2 空间频率

function y=fSF(A)
    A=double(A);
    [rows,cols]=size(A);
    tempA=0;tempB=0;
    for i=1:rows 
        for j=2:cols
            temp=(A(i,j)-A(i,j-1))^2;
            tempA=tempA+temp;
        end
    end
    for j=1:rows 
        for i=2:cols
            temp=(A(i,j)-A(i-1,j))^2;
            tempA=tempA+temp;
        end
    end
    RF=(1/(rows*cols))*tempA;
    CF=(1/(rows*cols))*tempB;
    y=(RF+CF)^0.5;
end

2.3 信息熵

function varargout= fshang(varargin)
%函数功能:
%     函数msg求出输入图像的熵
%----------------------------------%

if nargin<1         %判断输入变量的个数
    error('输入参数必须大于等于1.');
elseif nargin==1
    varargout{1}=f(varargin{1});
end
end

function y= f(x)
x=uint8(x);
temp=unique(x);   %temp就是x中全部不同的元素,例如x=[1,1,3,4,1,5];那么temp=[1;3;4;5]
temp=temp';
len=length(temp); %求出x矩阵中不同元素的个数
p=zeros(1,len);   %p向量用来存储矩阵x中每个不同元素的个数
[m,n]=size(x);
for k=1:len
    for i=1:m
        for j=1:n
            if x(i,j)==temp(1,k)
                p(1,k)=p(1,k)+1;
            end
        end
    end
end
for k=1:len
    p(1,k)=p(1,k)/(m*n);  %求出每个不同元素出现的频率
    p(1,k)=-p(1,k)*log2(p(1,k));
end
y=sum(p);
end

⛄三、 基于有参考的理想(目标)图像

3.1 均方根误差

function varargout= fjunfang(varargin)

if nargin<2
    error('输入参数必须大于等于2.');
elseif nargin==2
    varargout{1}=h(varargin{1},varargin{2});
end
end

function r=h(f,g)
f=double(f);
g=double(g);
[m,n]=size(f);

temp=[];
for i=1:m
    for j=1:n
        temp(i,j)=(f(i,j)-g(i,j))^2;
    end
end

r=sqrt(sum(sum(temp))/(m*n));

end


3.2 峰值信噪比

function varargout= fSNR(varargin)

if nargin<2
    error('输入参数必须大于等于2.');
elseif nargin==2
    varargout{1}=h(varargin{1},varargin{2});
end
end

function r=h(f,g)
f=double(f);
g=double(g);
[m,n]=size(f);

temp=[];
for i=1:m
    for j=1:n
        temp(i,j)=(f(i,j)-g(i,j))^2;
    end
end

r=sqrt(sum(sum(temp))/(m*n));


3.3 相关系数

function coeff = myPearson(X , Y)    
if length(X) ~= length(Y)  
    error('两个数值数列的维数不相等');  
    return;  
end  
  
fenzi = sum(X .* Y) - (sum(X) * sum(Y)) / length(X);  
fenmu = sqrt((sum(X .^2) - sum(X)^2 / length(X)) * (sum(Y .^2) - sum(Y)^2 / length(X)));  
coeff = fenzi / fenmu;  
  
end %函数myPearson结束 

⛄四 基于有参考的源图像

4.1 交叉熵

clc;clear;close all;
A=imread(‘test2.jpg’);B=imread(‘1.tif’);C=imread(‘2.tif’);

[m,n]=size(A);
a=zeros(1,256);
for i=1:m
for j=1:n
a(1,A(i,j)+1)=a(1,A(i,j)+1)+1;
end
end
b=zeros(1,256);
for i=1:m
for j=1:n
b(1,B(i,j)+1)=b(1,B(i,j)+1)+1;
end
end
c=zeros(1,256);
for i=1:m
for j=1:n
c(1,C(i,j)+1)=c(1,C(i,j)+1)+1;
end
end
%_____________________________________________________%
a=double(a);b=double(b);c=double©;
a=a/(mn);b=b/(mn);c=c/(m*n);

cen1=0;
for i=1:256
if a(1,i)0
temp3=0;
else
temp1=b(1,i)/a(1,i);
temp2=log2(temp1);
if temp2
-Inf
temp2=0;
end
temp3=b(1,i)*temp2;
end
cen1=cen1+temp3;
end
cen2=0;
for i=1:256
if a(1,i)0
temp3=0;
else
temp1=c(1,i)/a(1,i);
temp2=log2(temp1);
if temp2
-Inf
temp2=0;
end
temp3=c(1,i)*temp2;
end
cen2=cen2+temp3;
end

cen=(cen1cen1+cen2cen2)/2;
cen=sqrt(cen);
fprintf(‘\n交叉熵为:%f\n’,cen);

4.2 边缘信息保持度

```c
I=imread(''); 
I2=imread('');          % 分别表示原始图像,和处理后图像
imU=I(1:end-1, :);  
imD=I(2:end, :);         % 上部,下部
imL=I(:, 1:end-1);
imR=I(:, 2:end);         % 左部,右部;

im2U=I2(1:end-1, :);  
im2D=I2(2:end, :);         % 上部,下部
im2L=I2(:, 1:end-1);
im2R=I2(:, 2:end);    

EPI_H = sum(sum(abs(imR - imL)))/sum(sum(abs(im2R - im2L)));
EPI_V = sum(sum(abs(imU - imD)))/sum(sum(abs(im2D - im2D)));

fprint('水平保持度为%f\n,竖直保持度为%f\n',EPI_H,EPI_V)

 
3.3 结构相似度 
clc;
clear;
im1=imread('1.jpg');
im2=imread('2.jpg');
img1=double(im1);
img2=double(im2);
[mssim,ssim_map] = ssim(img1, img2);
fin=mssim
function [mssim, ssim_map] = ssim(img1, img2, K, window, L)
%Input : (1) img1: the first image being compared
%        (2) img2: the second image being compared
%        (3) K: constants in the SSIM index formula (see the above
%            reference). defualt value: K = [0.01 0.03]
%        (4) window: local window for statistics (see the above
%            reference). default widnow is Gaussian given by
%            window = fspecial('gaussian', 11, 1.5);
%        (5) L: dynamic range of the images. default: L = 255
%
%Output: (1) mssim: the mean SSIM index value between 2 images.
%            If one of the images being compared is regarded as 
%            perfect quality, then mssim can be considered as the
%            quality measure of the other image.
%            If img1 = img2, then mssim = 1.
%        (2) ssim_map: the SSIM index map of the test image. The map
%            has a smaller size than the input images. The actual size:
%            size(img1) - size(window) + 1.
%
%Default Usage:
%   Given 2 test images img1 and img2, whose dynamic range is 0-255
%
%   [mssim ssim_map] = ssim_index(img1, img2);
%
%Advanced Usage:
%   User defined parameters. For example
%
%   K = [0.05 0.05];
%   window = ones(8);
%   L = 100;
%   [mssim ssim_map] = ssim_index(img1, img2, K, window, L);
%
%See the results:
%
%   mssim                        %Gives the mssim value
%   imshow(max(0, ssim_map).^4)  %Shows the SSIM index map
%
%========================================================================


if (nargin < 2 || nargin > 5)
%    ssim_index = -Inf;
   ssim_map = -Inf;
   return;
end

if (size(img1) ~= size(img2))
%    ssim_index = -Inf;
   ssim_map = -Inf;
   return;
end

[M N] = size(img1);

if (nargin == 2)
   if ((M < 11) || (N < 11))   % 图像大小过小,则没有意义。
%            ssim_index = -Inf;
           ssim_map = -Inf;
      return
   end
   window = fspecial('gaussian', 11, 1.5);        % 参数一个标准偏差1.5,11*11的高斯低通滤波。
   K(1) = 0.01;                                                                      % default settings
   K(2) = 0.03;                                                                      %
   L = 255;                                  %
end

if (nargin == 3)
   if ((M < 11) || (N < 11))
%            ssim_index = -Inf;
           ssim_map = -Inf;
      return
   end
   window = fspecial('gaussian', 11, 1.5);
   L = 255;
   if (length(K) == 2)
      if (K(1) < 0 || K(2) < 0)
%                    ssim_index = -Inf;
                   ssim_map = -Inf;
                   return;
      end
   else
%            ssim_index = -Inf;
           ssim_map = -Inf;
           return;
   end
end

if (nargin == 4)
   [H W] = size(window);
   if ((H*W) < 4 || (H > M) || (W > N))
%            ssim_index = -Inf;
           ssim_map = -Inf;
      return
   end
   L = 255;
   if (length(K) == 2)
      if (K(1) < 0 || K(2) < 0)
%                    ssim_index = -Inf;
                   ssim_map = -Inf;
                   return;
      end
   else
%            ssim_index = -Inf;
           ssim_map = -Inf;
           return;
   end
end

if (nargin == 5)
   [H W] = size(window);
   if ((H*W) < 4 || (H > M) || (W > N))
%            ssim_index = -Inf;
           ssim_map = -Inf;
      return
   end
   if (length(K) == 2)
      if (K(1) < 0 || K(2) < 0)
%                    ssim_index = -Inf;
                   ssim_map = -Inf;
                   return;
      end
   else
%            ssim_index = -Inf;
           ssim_map = -Inf;
           return;
   end
end
%%
C1 = (K(1)*L)^2;    % 计算C1参数,给亮度L(x,y)用。
C2 = (K(2)*L)^2;    % 计算C2参数,给对比度C(x,y)用。
window = window/sum(sum(window)); %滤波器归一化操作。
img1 = double(img1); 
img2 = double(img2);

mu1   = filter2(window, img1, 'valid');  % 对图像进行滤波因子加权
mu2   = filter2(window, img2, 'valid');  % 对图像进行滤波因子加权

mu1_sq = mu1.*mu1;     % 计算出Ux平方值。
mu2_sq = mu2.*mu2;     % 计算出Uy平方值。
mu1_mu2 = mu1.*mu2;    % 计算Ux*Uy值。

sigma1_sq = filter2(window, img1.*img1, 'valid') - mu1_sq;  % 计算sigmax (标准差)
sigma2_sq = filter2(window, img2.*img2, 'valid') - mu2_sq;  % 计算sigmay (标准差)
sigma12 = filter2(window, img1.*img2, 'valid') - mu1_mu2;   % 计算sigmaxy(标准差)

if (C1 > 0 && C2 > 0)
   ssim_map = ((2*mu1_mu2 + C1).*(2*sigma12 + C2))./((mu1_sq + mu2_sq + C1).*(sigma1_sq + sigma2_sq + C2));
else
   numerator1 = 2*mu1_mu2 + C1;
   numerator2 = 2*sigma12 + C2;
   denominator1 = mu1_sq + mu2_sq + C1;
   denominator2 = sigma1_sq + sigma2_sq + C2;
   ssim_map = ones(size(mu1));
   index = (denominator1.*denominator2 > 0);
   ssim_map(index) = (numerator1(index).*numerator2(index))./(denominator1(index).*denominator2(index));
   index = (denominator1 ~= 0) & (denominator2 == 0);
   ssim_map(index) = numerator1(index)./denominator1(index);
end

mssim = mean2(ssim_map);

return
end
 

## ⛄四、matlab版本及参考文献
**1 matlab版本**
2014a

**2 参考文献**
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.

**3 备注**
简介此部分摘自互联网,仅供参考,若侵权,联系删除



**🍅 仿真咨询
1 各类智能优化算法改进及应用**
生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化

**2 机器学习和深度学习方面**
卷积神经网络(CNN)、LSTM、支持向量机(SVM)、最小二乘支持向量机(LSSVM)、极限学习机(ELM)、核极限学习机(KELM)、BP、RBF、宽度学习、DBN、RF、RBF、DELM、XGBOOST、TCN实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断

**3 图像处理方面**
图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知

**4 路径规划方面**
旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划、天线线性阵列分布优化、车间布局优化

**5 无人机应用方面**
无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配

**6 无线传感器定位及布局方面**
传感器部署优化、通信协议优化、路由优化、目标定位优化、Dv-Hop定位优化、Leach协议优化、WSN覆盖优化、组播优化、RSSI定位优化

**7 信号处理方面**
信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号、信号配时优化

**8 电力系统方面**
微电网优化、无功优化、配电网重构、储能配置

**9 元胞自动机方面**
交通流 人群疏散 病毒扩散 晶体生长

**10 雷达方面**
卡尔曼滤波跟踪、航迹关联、航迹融合
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

海神之光

有机会获得赠送范围1份代码

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值