def peak_snr(img1, img2):
 if (img1.ndim == 3):
  (img1, img2) = (rgb2gray(img1.copy()), rgb2gray(img2.copy()))
 img1 = skimage.img_as_float(img1)
 img2 = skimage.img_as_float(img2)
 mse = ((1.0 / img1.size) * np.square((img1 - img2)).sum())
 (_, max_) = dtype_range[img1.dtype.type]
 return (20 * np.log((max_ / mse)))

def peak_snr ( img1 , img2 ) : if ( img1 . ndim == 3 ) : ( img1 , img2 ) = ( rgb2gray ( img1 . copy ( ) ) , rgb2gray ( img2 . copy ( ) ) ) img1 = skimage . img_as_float ( img1 ) img2 = skimage . img_as_float ( img2 ) mse = ( ( 1.0 / img1 . size ) * np . square ( ( img1 - img2 ) ) . sum ( ) ) ( _ , max_ ) = dtype_range [ img1 . dtype . type ] return ( 20 * np . log ( ( max_ / mse ) ) )
peak signal to noise ratio of two images parameters img1 : array-like img2 : array-like returns peak_snr : float peak signal to noise ratio .