I. Classification of evaluation indicators

For fused images, the evaluation indexes can be divided into three categories as follows: 1) based on statistical features without reference; 2) based on ideal (target) images with reference; 3) based on source images with reference

Based on unreferenced statistical features

2.1 Average gradient algorithm

function outval=ftidu(img) 
    A=double(img); [r,c]=size(A); [dzdx,dzdy]=gradient(A); % find the gradient of X and the gradient of Y, s=sqrt((dzdx.^2+dzdy.^2). /2); 
        g=sum(sum(s))/(r*c); 
    outval=mean(g); 
end
Copy the code

1.2 Spatial frequency

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
Copy the code

2.3 the information entropy

The function varargout = fshang (varargin) % function function: % function MSG the entropy of the input image % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - %if nargin<1% Determine the number of input variables error('Input parameter must be greater than or equal to 1.');
elseif nargin==1
    varargout{1}=f(varargin{1}); end end function y= f(x) x=uint8(x); temp=unique(x); %temp is all the different elements of x, such as x=[1.1.3.4.1.5]; The temp = [1;3;4;5]
temp=temp'; len=length(temp); % Find the number of different elements in the x matrix p=zeros(1,len); The %p vector is used to store the number of different elements in the matrix 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); % Find the frequency of occurrence of each different element p(1,k)=-p(1,k)*log2(p(1,k));
end
y=sum(p);
end
Copy the code

Based on the ideal (target) image with reference

3.1 Root mean square error

function varargout= fjunfang(varargin)

if nargin<2
    error('Input parameter must be greater than or equal to 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
Copy the code

3.2 Peak signal to noise ratio

function varargout= fSNR(varargin)

if nargin<2
    error('Input parameter must be greater than or equal to 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));
Copy the code

3.3 Correlation coefficient

function coeff = myPearson(X , Y)    
if length(X) ~= length(Y)  
    error('The dimensions of two numerical sequences are not equal');  
    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; The end % function myPearson endsCopy the code

Fourth, based on the source image with reference

4.1 cross entropy

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(c); a=a/(m*n); b=b/(m*n); 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=(cen1*cen1+cen2*cen2)/2;
cen=sqrt(cen);
fprintf('\n cross entropy is :%f\n',cen);
Copy the code

4.2 Edge information retention

I=imread("); I2=imread(''); % represents original image and processed image imU=I(1:end-1, :); imD=I(2:end, :); ImL =I(:, 1:end-1); imR=I(:, 2:end); % left, right; 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('The horizontal retention is %f\n and the vertical retention is % F \n',EPI_H,EPI_V)
Copy the code

3.3 Structural similarity

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)) % If the image size is too small, it is meaningless. % ssim_index = -Inf; ssim_map = -Inf;return
   end
   window = fspecial('gaussian'.11.1.5); One standard deviation for % parameters1.5.11*11Gaussian low pass filtering. 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; % Calculate the C1 parameter and assign brightness L (x, y) to it. C2 = (K(2)*L)^2; % Calculate the C2 parameter for contrast C (x, y). window = window/sum(sum(window)); % filter normalization operation. img1 =double(img1); 
img2 = double(img2);

mu1   = filter2(window, img1, 'valid'); Mu2 = filter2(window, img2,'valid'); % Weighted image filter factor mu1_SQ = mu1.*mu1; % calculates the Ux squared value. mu2_sq = mu2.*mu2; % calculates Uy squared. mu1_mu2 = mu1.*mu2; % Calculate the Ux*Uy value. sigma1_sq = filter2(window, img1.*img1,'valid') - mu1_sq; % sigmax (standard deviation) sigma2_sq = filter2(window, img2.*img2,'valid') - mu2_sq; % calculate sigmay (standard deviation) sigma12 = filter2(window, img1.*img2,'valid') - mu1_mu2; % Calculate sigmaxy (standard deviation)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
Copy the code

Fourth, note

Version: 2014 a