请写出图像融合评估指标 并用matlab写出计算这些指标的代码
时间: 2023-09-24 22:03:31 浏览: 137
图像融合的各种评价指标(matlab代码)
5星 · 资源好评率100%
常见的图像融合评估指标包括以下几种:
1. 均方误差(MSE)
2. 峰值信噪比(PSNR)
3. 结构相似性指数(SSIM)
4. 信息熵(Entropy)
5. 互信息(MI)
以下是用 Matlab 实现这些指标的代码:
1. 均方误差(MSE)
```matlab
function mse = computeMSE(img1, img2)
diff = double(img1) - double(img2);
mse = sum(diff(:).^2) / numel(img1);
end
```
2. 峰值信噪比(PSNR)
```matlab
function psnr = computePSNR(img1, img2)
mse = computeMSE(img1, img2);
psnr = 10 * log10((255^2) / mse);
end
```
3. 结构相似性指数(SSIM)
```matlab
function ssimval = computeSSIM(img1, img2)
k1 = 0.01;
k2 = 0.03;
L = 255;
c1 = (k1 * L)^2;
c2 = (k2 * L)^2;
mu1 = mean2(img1);
mu2 = mean2(img2);
sigma1 = std2(img1);
sigma2 = std2(img2);
sigma12 = cov2(img1, img2);
ssimval = ((2 * mu1 * mu2 + c1) * (2 * sigma12 + c2)) / ((mu1^2 + mu2^2 + c1) * (sigma1^2 + sigma2^2 + c2));
end
```
4. 信息熵(Entropy)
```matlab
function entropyval = computeEntropy(img)
[counts, ~] = imhist(img);
p = counts / sum(counts);
entropyval = -sum(p.*log2(p));
end
```
5. 互信息(MI)
```matlab
function mival = computeMI(img1, img2)
nbins = 256;
[counts1, ~] = imhist(img1, nbins);
[counts2, ~] = imhist(img2, nbins);
jointHist = histcounts2(img1(:), img2(:), nbins);
jointHist = jointHist / sum(jointHist(:));
p1 = counts1 / sum(counts1);
p2 = counts2 / sum(counts2);
mi = 0;
for i=1:nbins
for j=1:nbins
if jointHist(i,j) > 0
mi = mi + jointHist(i,j) * log2(jointHist(i,j) / (p1(i) * p2(j)));
end
end
end
mival = mi;
end
```
阅读全文