how to overcome this error?
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
Accepted Answer
More Answers (0)
Categories
Find more on Image Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!