# Creating a noise model with a fixed PSNR

My goal is to create a noise model so that the PSNR of the noisy image compared to the original is some pre-defined constant $\alpha$. This means the mean squared-error will also be a constant.

My model is as follows:

The additive noise is a random normally distributed variable with $\mu = 0$ and unknown $\sigma$.

$K(i,j) = I(i,j) + f(x; 0, \sigma)$

So,

$$MSE = \frac{1}{mn}\sum_{i = 0}^{m - 1}\sum_{j = 0}^{n - 1}\ [K(i,\ j) - I(i,\ j)]^2 = \frac{1}{mn}\sum_{i = 0}^{m - 1}\sum_{j = 0}^{n - 1}\ [\ f(x;\ 0,\ \sigma)]^2$$

where $$f(x;\ 0,\ \sigma) = \frac{1}{\sqrt{2\pi}\sigma}e^{\frac{-x^2}{2\sigma^2}}$$ i.e. the Gaussian pdf with unknown variance.

What I'm confused about is how to solve for sigma when the values of the pdf are supposed to be independent samples from the distribution. If I'm understanding correctly, this means that the MSE itself becomes a random variable and cannot be a constant.

If we were to make it a constant, wouldn't the values of $f(x)$ for each pixel have to already be known for the equation to be solvable? In which case the distribution would need to be already known to randomly sample the distribution to produce the values of $f(x)$...

Anyhow, if anyone has advice on how to construct noisy images with a pre-defined PSNR, that would be appreciated.

$$PSNR = 20 \cdot \log_{10}(MAX_I) - 10 \cdot \log_{10}(MSE)$$
1. To identify the max value of your image: $MAX_I$
2. Generate noise samples for $\sigma = 1$
3. Solve for $MSE$ in the equation above.
4. Scale all you generated noise samples by the same factor to achieve that $MSE$ value.