Calculation of psnr value in RGB image. I have calculated psnr using this code. But the result obtained is a complex number. What should be the error??
if true
function PSNR = psnrgb(I,W)
[m,n,p] = size(I);
[h,w,q] = size(W);
if m ~= h || n ~= w || p~=q
error(‘Two images must have the same size.’)
end
for k=1:p
for i=1:m
for j=1:n
delta=sum(I(i,j,k)-W(i,j,k).^2);
end
end
end
delta = 1/(m*n*p) * delta ;
PSNR = 10 * log10( 255^2/delta );
end
endif true
function PSNR = psnrgb(I,W)
[m,n,p] = size(I);
[h,w,q] = size(W);
if m ~= h || n ~= w || p~=q
error(‘Two images must have the same size.’)
end
for k=1:p
for i=1:m
for j=1:n
delta=sum(I(i,j,k)-W(i,j,k).^2);
end
end
end
delta = 1/(m*n*p) * delta ;
PSNR = 10 * log10( 255^2/delta );
end
end if true
function PSNR = psnrgb(I,W)
[m,n,p] = size(I);
[h,w,q] = size(W);
if m ~= h || n ~= w || p~=q
error(‘Two images must have the same size.’)
end
for k=1:p
for i=1:m
for j=1:n
delta=sum(I(i,j,k)-W(i,j,k).^2);
end
end
end
delta = 1/(m*n*p) * delta ;
PSNR = 10 * log10( 255^2/delta );
end
end image processing, steganography MATLAB Answers — New Questions