code: 
  
  
  
  
  
  
  import math
  import os
  
  import cva
  import numpy as np
  
  __A  							=  255.0
  
  
  
  
  
  
  
  def 			lowercase__  (				A_     ,			A_		)  ->							float:
  
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
         __UpperCAmelCase    							=np.mean((original - contrast) ** 2		)
         if mse == 0:
                return 100
  
         return 20 * math.logaa(PIXEL_MAX / math.sqrt(A_		)		)
  
  
  
  
  
  
  
  def 			lowercase__  (				)  ->							None:
  
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
         __UpperCAmelCase    							=os.path.dirname(os.path.realpath(A_		)		)
         # Loading images (original image and compressed image)
         __UpperCAmelCase    							=cva.imread(os.path.join(A_     ,			"""image_data/original_image.png"""		)		)
         __UpperCAmelCase    							=cva.imread(os.path.join(A_     ,			"""image_data/compressed_image.png"""		)     ,			1		)
  
         __UpperCAmelCase    							=cva.imread(os.path.join(A_     ,			"""image_data/PSNR-example-base.png"""		)		)
         __UpperCAmelCase    							=cva.imread(
             os.path.join(A_     ,			"""image_data/PSNR-example-comp-10.jpg"""		)     ,			1		)
  
         # Value expected: 29.73dB
         print("""-- First Test --"""		)
         print(F'''PSNR value is {peak_signal_to_noise_ratio(A_     ,			A_		)} dB'''		)
  
         # # Value expected: 31.53dB (Wikipedia Example)
         print("""\n-- Second Test --"""		)
         print(F'''PSNR value is {peak_signal_to_noise_ratio(A_     ,			A_		)} dB'''		)
  
  
  if __name__ == "__main__":
     main()
  
  
  
  
  
style_context: 
  
  
  
  
  
  
  from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
  from numpy import divide, inta, multiply, ravel, sort, zeros_like
  
  
  
  
  
  
  
  def 			lowercase__  (				A_:	int     ,			A_:	Any=3		)  ->							Dict:
  
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
         __UpperCAmelCase    							=int(mask / 2		)
         # copy image size
         __UpperCAmelCase    							=zeros_like(A_		)
         for i in range(A_     ,			gray_img.shape[0] - bd		):
                for j in range(A_     ,			gray_img.shape[1] - bd		):
                       # get mask according with mask
                       __UpperCAmelCase    							=ravel(gray_img[i - bd : i + bd + 1, j - bd : j + bd + 1]		)
                       # calculate mask median
                       __UpperCAmelCase    							=sort(A_		)[inta(divide((multiply(A_     ,			A_		))     ,			2		) + 1		)]
                       __UpperCAmelCase    							=median
         return median_img
  
  
  if __name__ == "__main__":
     # read original image
     __A  							=  imread("../image_data/lena.jpg")
     # turn image in gray scale value
     __A  							=  cvtColor(img, COLOR_BGR2GRAY)
  
     # get values with two different mask size
     __A  							=  median_filter(gray, 3)
     __A  							=  median_filter(gray, 5)
  
     # show result images
     imshow("median filter with 3x3 mask", medianaxa)
     imshow("median filter with 5x5 mask", medianaxa)
     waitKey(0)
  
  
  
  
  