when i run this codding, the following error are shown..please help me to solve this problem :(
이전 댓글 표시
>> A = 'File Burning.avi'
A =
File Burning.avi
>> B = 'File Burning1.avi'
B =
File Burning1.avi
>> char psnr_Value = PSNR(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 = Inf;
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
ans =
psnr_Value
=
PSNR(A,B)
??? Error using ==> eq
Matrix dimensions must agree.
댓글 수: 1
Andreas Goser
2012년 5월 15일
It is very unclear what you do, what your actual code is, where the error appear and even if you use PSNR from the FileExchange or a modified version.
답변 (2개)
Andreas Goser
2012년 5월 15일
In order to troubleshoot a "Matrix dimensions must agree." error, you can identify the line number of the line causing the error (not shown in your example) and add the WHOS command right above this line. By doing that, you will see why the matrix dimensions do no agree and you can fix the issue. Example:
a=1;
b=[2,3];
whos
Name Size Bytes Class Attributes
a 1x1 8 double
b 1x2 16 double
Walter Roberson
2012년 5월 15일
Calculating the PSNR of two strings is not useful. You need to read the files indicated by the strings and extract images to compare.
In your code, size(A) ~= size(B) would fail if the number of dimensions of the two arrays was not the same.
Your line
char psnr_Value = PSNR(A,B)
is valid coding, but the meaning of it would not be generally understood. It is equivalent of
['psnr_Value'; '= '; 'PSNR(A,B) ']
카테고리
도움말 센터 및 File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!