# How to calculate the signal-to-noise ratio (SNR) in an image?

I am working with an image X, I apply the "adaptive median filter" in it and I get the image Y. I'd like to measure the SNR in both in order to evaluate the quantity of noise deleted.

I know the formula to calculate the SNR is:

SNR = Psignal / Pnoise

but I don't know how to get these values from both images I have. I was thinking in substract the image X from Y and get the noise value. But I am not sure about the method.

• Unless you have access to the 'ground' truth where you can actually separate the signal and the noise, and calculate statistics on that, this is an ill posed problem and there is no general solution to that, but only domain specific approaches. This is an 'active' (or at least open) field of research. There are a few data driven methods to determine SNR on a single image, that exploit some assumptions on the spectral properties of the signal and the noise, and these are normally relatively broad and reasonable assumption. You may want to do a literature research on those. Apr 6 '17 at 9:31

You want to measure the signal to noise ratio on each image. This is akin to asking what the error is of a single number: you don't know. What's the error of five? That doesn't make any sense.

In this case it might be more interesting to find out the the SNR of the process. Here's how you might go about that:

Start with a "perfect" image. That is, an image who's noise is so low that it could be considered negligible. Use some very high quality, standard or constructed image for this purpose, like lenna. That's your signal.

Add some noise. Usually we use gaussian white noise for this purpose. That's your noise.

Now, the combined image (your "noisy image") has a signal to noise ratio with some meaning because you can compare it to the perfect image, eg pixel by pixel.

After processing it with your adaptive median filter, your final image (your "processed image") also has a signal to noise ratio because, again, you can compare it to your perfect image in the same way. It is now meaningful to ask if the SNR has gone up or down and by how much.

• Well, my main goal is to measure the amount of noise in both image X and image Y, if the SNR increase I will know if the filter removed the noise. Is my approach incorrect? In the real world you don't add noise to the images, the images are noisy and you must to apply filters to remove the noise. I am looking for a good technique to know if I removed noise. Is not SNR for that purpose?
– omar
Mar 13 '13 at 1:18
• In "the real world" you don't know how much noise is in the image (or any data), which is why you create artificially noisy images. This is a standard technique in image processing research. Mar 13 '13 at 14:59
• Thank you Bjorn Roche; But how we calculate the SNR Knowing that there are several way to calculate it I'm confused which one can I use? 'in this case for exemple' Jul 11 '13 at 10:22
• @Ahmed: That's a topic for a different question. Jul 11 '13 at 19:06
1. Calculate the $P_{signal}$ as the mean of pixel values.
2. Calculate the $P_{noise}$ and the standard deviation or error value of the pixel values.
3. Take the ratio or you may use $SNR=10\log_{10}(P_{signal}/P_{noise})$ to express the result in decibel.