code: def psnr(data1, data2, method='starck', max_pix=255):
      r
  
      if method == 'starck':
  
          return (20 * np.log10((data1.shape[0] * np.abs(np.max(data1) -
                  np.min(data1))) / np.linalg.norm(data1 - data2)))
  
      elif method == 'wiki':
  
          return (20 * np.log10(max_pix) - 10 *
                  np.log10(mse(data1, data2)))
  
      else:
  
          raise ValueError('Invalid PSNR method. Options are "starck" and '
                           '"wiki"')
docs: r"""Peak Signal-to-Noise Ratio
  
      This method calculates the Peak Signal-to-Noise Ratio between an two data
      sets
  
      Parameters
      ----------
      data1 : np.ndarray
          First data set
      data2 : np.ndarray
          Second data set
      method : str {'starck', 'wiki'}, optional
          PSNR implementation, default ('starck')
      max_pix : int, optional
          Maximum number of pixels, default (max_pix=255)
  
      Returns
      -------
      float PSNR value
  
      Examples
      --------
      >>> from modopt.math.stats import psnr
      >>> a = np.arange(9).reshape(3, 3)
      >>> psnr(a, a + 2)
      12.041199826559248
  
      >>> psnr(a, a + 2, method='wiki')
      42.110203695399477
  
      Notes
      -----
      'starck':
  
          Implements eq.3.7 from _[S2010]
  
      'wiki':
  
          Implements PSNR equation on
          https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio
  
          .. math::
  
              \mathrm{PSNR} = 20\log_{10}(\mathrm{MAX}_I -
              10\log_{10}(\mathrm{MSE}))