I am new to matlab. When i run my code, the output is printed multiple times with different values. What's wrong with this code?
InputImage=imread("img1.png");
ReconstructedImage=imread("img2.png");
n=size(InputImage);
M=n(1);
N=n(2);
MSE = sum(sum((InputImage-ReconstructedImage).^2))/(M*N);
PSNR = 10*log10(256*256/MSE);
fprintf('\nMSE: %7.2f ', MSE);
fprintf('\nPSNR: %9.7f dB', PSNR);
Output:
MSE: 0.70
MSE: 0.61
MSE: 0.99
PSNR: 49.7147717 dB
PSNR: 50.3459133 dB
PSNR: 48.1905858 dB

 Akzeptierte Antwort

Star Strider
Star Strider am 1 Jan. 2020

0 Stimmen

The .png image is an (MxNx3) matrix, so the calculations occur for each ‘page’ in the third dimension.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by