# Why psnr function in matlab returns a negative value for an image corrupted with Cauchy noise?

I have written the following matlab code for producing a noisy image corrupted by Cauchy noise but when I compute the psnr value of the noisy image using psnr function in matlab, it returns a negative value while according to the paper that I have implemented its results, the psnr value for the cameraman test image of size 256 by 256 and 0.02 of Cauchy noise must be around 19. I appreciate it if someone could please help me to solve this problem.

The image intensity range is [0,1] for cameraman test image.

refimg = im2double(imread('cameraman.png')); % original image
img_height = size(refimg,1);
img_width = size(refimg,2);
refimg = refimg(1:img_height,1:img_width);

rng(0);
r1 = random('Normal',0, 1,[img_height img_width]);
r2 = random('Normal',0, 1,[img_height img_width]);

n = 0.02; % the noise level
u0 = refimg + n.*(r1./r2);

figure(1); imshow(u0);

PSNR_noisy = psnr(refimg,u0)

• Your noise level is 0.02. What is the level of your signal ? Nov 7, 2021 at 19:32
• This is a duplicate question, asked and answered over on SO: stackoverflow.com/q/69872113/7328782 Nov 8, 2021 at 2:18