Text output is printed multiple times

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

 採用された回答

Star Strider
Star Strider 2020 年 1 月 1 日

0 投票

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImages についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by