How to measure the peak-to-noise ratio of images?

I have the following images:

enter image description here

Damaged by 30% salt and pepper noise

enter image description here

After noise reduction

I have images with various technologies

How can I compare which method is best in terms of noise reduction

function PSNR = PeakSignaltoNoiseRatio(origImg, distImg) origImg = double(origImg); distImg = double(distImg); [MN] = 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 

What two images should I take to calculate PSNR?

+5
source share
2 answers

Have you checked the Wikipedia article on PSNR ? For example, it gives a cleaner formula that will correct your code (for example, why do you check if MSE is> 0? If you defined the MSE correctly, it should be greater than 0. Also, it looks like Matlab code, so use the log10() function log10() to preserve some confusing basic transformations. Finally, make sure that the input for this function is actually a quantized image on a scale of 0-255, not a double image between 0 and 1).

Your question is unclear. If you want to use PSNR as an indicator of performance, then you must calculate the PSNR of each unnamed method compared to the original and report these numbers. This probably will not give a very good overview of which methods work better, but this is only the beginning. Another method may be to manually select smaller subregions of the original image, which, in your opinion, correspond to various qualitative phenomena, such as a window in the background, a window in the foreground, and a window covering these two elements. Then calculate the PSNR only for these windows, repeating again for each impaired result compared to the original. At the end, you want a table showing the PSNR of each other method compared to the original, possibly with this sub-window splitting.

You might want to take a look at more complex methods depending on which application it is for. A very useful chapter on noise reduction in Tony Chan’s book ( link ).

+1
source

Here is an example of Jython / Python using the DataMelt program. Put these lines in the file "test.py" and run inside the DataMelt. It will print the PSNR value for 2 uploaded images. Replace the file names if you have different images.

 from Catalano.Imaging.Tools import ObjectiveFidelity from Catalano.Imaging import FastBitmap from jhplot import * print Web.get("http://jwork.org/dmelt/examples/data/logo_jhepwork.png") print Web.get("http://jwork.org/dmelt/examples/data/logo_jhepwork_noisy.png") original=FastBitmap("logo_jhepwork.png") original.toGrayscale() reconstructed=FastBitmap("logo_jhepwork_noisy.png") reconstructed.toGrayscale() img=ObjectiveFidelity(original,reconstructed) print "Peak signal-to-noise ratio (PSNR)=",img.getPSNR() 
0
source

Source: https://habr.com/ru/post/1399661/


All Articles