how to overcome this error?

3 ビュー (過去 30 日間)
STUDENT_HUB
STUDENT_HUB 2014 年 5 月 29 日
コメント済み: STUDENT_HUB 2014 年 5 月 30 日
??? Error using ==> PSNR at 5 The size of the 2 matrix are unequal
Error in ==> SN at 71 psn(1,ii)=PSNR(im1,img1);
  • SN.m CODE attached
  • PSNR.m CODE
function psnr_Value = PSNRN(A,B) % PSNR (Peak Signal to noise ratio)
if (size(A) ~= size(B)) error('The size of the 2 matrix are unequal')
psnr_Value = NaN;
return;
elseif (A == B)
disp('Images are identical: PSNR has infinite value')
psnr_Value = 100;
return;
else
maxValue = double(max(A(:)));
% Calculate MSE, mean square error.
mseImage = (double(A) - double(B)) .^ 2;
[rows columns] = size(A);
mse = sum(mseImage(:)) / (rows * columns);
% Calculate PSNR (Peak Signal to noise ratio)
psnr_Value = 10 * log10( 256^2 / mse);
end
end % function END

採用された回答

dpb
dpb 2014 年 5 月 29 日
f (size(A) ~= size(B)) error('The size of the 2 matrix are unequal')
The function is designed for images that are the same size -- to "solve" the problem, use it as intended. Either make sure are using images that are fundamentally the same resolution or clip the larger to be the size of the smaller before calling the function.
  1 件のコメント
STUDENT_HUB
STUDENT_HUB 2014 年 5 月 30 日
Thanks for your answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by