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

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개)

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
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) ']

카테고리

질문:

2012년 5월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by