title: How to measure Peak signal to noise ratio of images?
body: <p>I have the following images :</p>
  
  <p><img src="https://i.stack.imgur.com/hs8ym.jpg" alt="enter image description here"></p>
  
  <p>Corrupted with 30% salt and pepper noise</p>
  
  <p><img src="https://i.stack.imgur.com/NvNVs.jpg" alt="enter image description here"></p>
  
  <p>After denoising</p>
  
  <p>I have denoised images with various techniques</p>
  
  <p>How do i compare which method is the best in terms of denoising</p>
  
  <pre><code>    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 &gt; 0)
      PSNR = 10*log(255*255/MSE) / log(10);
  else
      PSNR = 99;
  end
  </code></pre>
  
  <p>which two images should i take to calculate the PSNR? </p>