how to overcome this error?
2 views (last 30 days)
Show older comments
??? 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
0 Comments
Accepted Answer
dpb
on 29 May 2014
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.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!