MATLAB图像复原写简单PSNR、SSIM、MSE、MAE、SNR、ISNR代码
时间: 2023-09-22 09:10:21 浏览: 171
下面是MATLAB图像复原中常用的一些评价指标的简单代码实现:
1. PSNR(峰值信噪比)
```matlab
function psnr_value = psnr(original_image, restored_image)
mse_value = mean(mean((double(original_image) - double(restored_image)).^2));
if(mse_value == 0)
psnr_value = 100;
else
psnr_value = 10*log10(255^2/mse_value);
end
end
```
2. SSIM(结构相似性)
```matlab
function ssim_value = ssim(original_image, restored_image)
k1 = 0.01;
k2 = 0.03;
L = 255;
C1 = (k1*L)^2;
C2 = (k2*L)^2;
mu1 = mean2(original_image);
mu2 = mean2(restored_image);
sigma1 = std2(original_image);
sigma2 = std2(restored_image);
sigma12 = cov2(original_image,restored_image);
numerator = (2*mu1*mu2 + C1)*(2*sigma12 + C2);
denominator = (mu1^2 + mu2^2 + C1)*(sigma1^2 + sigma2^2 + C2);
ssim_value = numerator/denominator;
end
```
3. MSE(均方误差)
```matlab
function mse_value = mse(original_image, restored_image)
mse_value = mean(mean((double(original_image) - double(restored_image)).^2));
end
```
4. MAE(平均绝对误差)
```matlab
function mae_value = mae(original_image, restored_image)
mae_value = mean(mean(abs(double(original_image) - double(restored_image))));
end
```
5. SNR(信噪比)
```matlab
function snr_value = snr(original_image, restored_image)
mse_value = mean(mean((double(original_image) - double(restored_image)).^2));
snr_value = 10*log10(mean(mean(double(original_image).^2))/mse_value);
end
```
6. ISNR(改进信噪比)
```matlab
function isnr_value = isnr(original_image, restored_image, noise_image)
mse_restored = mean(mean((double(original_image) - double(restored_image)).^2));
mse_noise = mean(mean((double(original_image) - double(noise_image)).^2));
isnr_value = 10*log10(mse_noise/mse_restored);
end
```
阅读全文