Click here to Skip to main content
15,891,763 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I've corrupted some images using imnoise() fucntion!

However I've not been able to specify the peak signal to noise ratio i want.

Any advice?

Regards Opul3nce
Posted

1 solution

This depends on which type of noise you are adding. I will presuming you are adding zero-mean Gaussian noise; firstly because that's mostly likely what you are using and secondly because its nice and easy to work with.

If we have a quick look on Wikipedia[^] for PSNR we get a whole bunch of useful stuff. First lets consider the formula for the MSE; the two images are the same and will cancel each other out, just leaving the Gaussian noise. So you need to set the mean square of the Gaussian noise to the right level.

Rearranging the second (will become clear why I chose that one shortly) PSNR formula to find out the desired MSE should result in this, assuming I haven't made any foolish maths errors:

sqrt(MSE) = MAXi/(10^(PSNR/20))

Now since we are just looking at the noise (since the two actual images cancelled out) and the mean of our Gaussian is zero, then the sqrt(MSE) is just the RMS[^] of the noise and by a happy coincidence the RMS is simply the variance of the Gaussian.

Probably worth looking for a good text book on signals, unfortunately I can't think of an optimum choice off the top of my head.

Charles Keepax
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900