马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
以下两个程序都有点问题 希望高手指点以下:
function dPSNR = psnr(ImageA,ImageB)
if (size(ImageA,1) ~= size(ImageB,1)) or (size(ImageA,2) ~= size(ImageB,2))
error('ImageA <> ImageB');
dPSNR = 0;
return ;
end
ImageA=double(ImageA);
ImageB=double(ImageB);
M = size(ImageA,1);
N = size(ImageA,2);
d = 0 ;
for i = 1:M
for j = 1:N
d = d + (ImageA(i,j) - ImageB(i,j)).^2 ;
end
end
dPSNR = 10*log10((M*N*max(max(ImageA.^2)))/d) ;
return
Error in ==> psnr2 at 3
if (size(ImageA,1) ~= size(ImageB,1)) or (size(ImageA,2) ~= size(ImageB,2))
-------------------------------------------------------------------------------------------------------------------
function [PSNR,mse]=psnr(X,Y)
% function [PSNR,mse]=psnr(X,Y)
% Peak signal to noise ratio of the difference between images and the mean square error
% If the second input Y is missing then the PSNR and MSE of X itself becomes the output (as if Y=0).
if nargin<2, D=X;
else
if any(size(X)~=size(Y)), error('The input size is not equal to each other');
end
X=double(X);
Y=double(Y);
D=X-Y;
end
mse=sum(D(:).*D(:))/prod(size(X));
PSNR=10*log10(255^2/mse);
Error in ==> psnr at 6
if nargin<2, D=X;
[ 本帖最后由 buttle 于 2008-5-23 10:08 编辑 ] |