MATLAB内置代码写简单图像复原PSNR、SSIM、MSE、MAE、SNR、ISNR代码
时间: 2023-09-28 18:04:22 浏览: 88
图像复原的matlab代码
5星 · 资源好评率100%
以下是MATLAB内置函数计算图像复原的PSNR、SSIM、MSE、MAE、SNR、ISNR的示例代码:
```matlab
% 读入原始图像和复原图像
original_image = imread('original.jpg');
restored_image = imread('restored.jpg');
% 计算 PSNR
peaksnr = psnr(restored_image, original_image);
fprintf('\n The Peak-SNR value is %0.4f', peaksnr);
% 计算 SSIM
[ssimval, ssimmap] = ssim(restored_image, original_image);
fprintf('\n The SSIM value is %0.4f', ssimval);
% 计算 MSE
mse = immse(restored_image, original_image);
fprintf('\n The MSE value is %0.4f', mse);
% 计算 MAE
mae = sum(abs(double(restored_image(:))-double(original_image(:))))/numel(original_image);
fprintf('\n The MAE value is %0.4f', mae);
% 计算 SNR
snr = 10*log10(sum(original_image(:).^2)/sum((original_image(:)-restored_image(:)).^2));
fprintf('\n The SNR value is %0.4f dB', snr);
% 计算 ISNR
isnr = 10*log10(sum((original_image(:)-restored_image(:)).^2)/sum((original_image(:)-noisy_image(:)).^2));
fprintf('\n The ISNR value is %0.4f dB', isnr);
```
其中,`original_image`和`restored_image`分别为原始图像和复原图像的矩阵,可以使用MATLAB中的`imread`函数读入图像文件。这段代码中计算了PSNR、SSIM、MSE、MAE、SNR、ISNR的值,并将结果打印出来。
阅读全文