Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to measure Peak signal to noise ratio of images?

I have the following images :

enter image description here

Corrupted with 30% salt and pepper noise

enter image description here

After denoising

I have denoised images with various techniques

How do i compare which method is the best in terms of denoising

    function PSNR = PeakSignaltoNoiseRatio(origImg, distImg)

origImg = double(origImg);
distImg = double(distImg);

[M N] = size(origImg);
error = origImg - distImg;
MSE = sum(sum(error .* error)) / (M * N);

if(MSE > 0)
    PSNR = 10*log(255*255/MSE) / log(10);
else
    PSNR = 99;
end

which two images should i take to calculate the PSNR?

like image 551
vini Avatar asked Nov 13 '22 09:11

vini


1 Answers

Did you check the Wikipedia article on PSNR? For one, it gives a cleaner formula that would fix up your code (for example, why are you checking whether MSE > 0? If you defined MSE right, it has to be greater than 0. Also, this looks to be Matlab code, so use the log10() function to save some confusing base conversions. Lastly, be sure that the input to this function is actually a quantized image on the 0-255 scale, and not a double-valued image between 0 and 1).

Your question is unclear. If you want to use PSNR as a metric for performance, then you should compute the PSNR of each denoised method against the original and report those numbers. That probably won't give a very good summary of which methods are doing better, but it's a start. Another method could be to hand-select smaller sub-regions of the original image that you think correspond to different qualitative phenomena, such as a window on the background, a window on the foreground, and a window spanning the two. Then compute the PSNR for only those windows, again repeated for each denoised result vs. the original. In the end, you want a table showing PSNR of each different method as compared to the original, possibly with this sub-window breakdown.

You may want to look into more sophisticated methods depending on what application this is for. The chapter on total variation image denoising in Tony Chan's book is very helpful ( link ).

like image 80
ely Avatar answered Dec 18 '22 09:12

ely