MSE and PSNR code for image

1 view (last 30 days)
Gayatri B
Gayatri B on 19 Sep 2019
Edited: Gayatri B on 19 Sep 2019
I'm calculating MSE and PSNR values for an image. Following is the code for it. Can you explain this code ? It seems quite complicated. I think m, n, d are height, width, length respectively.
a=imread('colorlable.jpg');
[m,n,d]=size(a);
kmax=floor((m*n)/(m+n+1));
da=double(a);
U=zeros(m,m);S=zeros(m,n);V=zeros(n,n);e=zeros(kmax,d);cr=zeros(kmax,1);rmse=zeros(kmax,d);
for i=1:d
[U(:,:,i),S(:,:,i),V(:,:,i)]=svd(da(:,:,i));
end
for k=1:kmax
ca=zeros(m,n,d);
MSE=m*n/(k*(m+n+1));
fprintf('MSE value at %f.\n',MSE);
SNR =(10*log10((sum(m.^2)))/MSE);
fprintf('PSNR value at %4f.\n',SNR);
end

Answers (0)

Community Treasure Hunt

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

Start Hunting!