




def 	lowerCAmelCase_	(     lowerCamelCase:				list  )    ->	bool:


      '''simple docstring'''




      if not isinstance(__A   , __A  ):
            raise ValueError('Input series is not valid, valid series - [2, 4, 8]'  )
      if len(__A  ) == 0:
            raise ValueError('Input list must be a non empty list'  )
      if len(__A  ) == 1:
            return True
      try:
            lowerCamelCase__					     = series[1] / series[0]
            for index in range(len(__A  ) - 1  ):
                  if series[index + 1] / series[index] != common_ratio:
                        return False
      except ZeroDivisionError:
            return False
      return True

def 	lowerCAmelCase_	(     lowerCamelCase:				list  )    ->	float:


      '''simple docstring'''




      if not isinstance(__A   , __A  ):
            raise ValueError('Input series is not valid, valid series - [2, 4, 8]'  )
      if len(__A  ) == 0:
            raise ValueError('Input list must be a non empty list'  )
      lowerCamelCase__					     = 1
      for value in series:
            answer *= value
      return pow(__A   , 1 / len(__A  )  )


if __name__ == "__main__":
      import doctest

      doctest.testmod()


import math
import os

import cva
import numpy as np

__UpperCAmelCase      = 255.0





def 	snake_case_      (__A     :						float					,   __A     :						float     )			->	float:
   __lowerCAmelCase  :			Any					    =						np.mean((original - contrast) ** 2     )
   if mse == 0:
      return 1_0_0

   return 2_0 * math.logaa(PIXEL_MAX / math.sqrt(__A     )     )





def 	snake_case_      ()			->	None:
   __lowerCAmelCase  :			int					    =						os.path.dirname(os.path.realpath(__A     )     )
   # Loading images (original image and compressed image)
   __lowerCAmelCase  :			Tuple					    =						cva.imread(os.path.join(__A					,   """image_data/original_image.png"""     )     )
   __lowerCAmelCase  :			Dict					    =						cva.imread(os.path.join(__A					,   """image_data/compressed_image.png"""     )					,   1     )

   __lowerCAmelCase  :			Optional[int]					    =						cva.imread(os.path.join(__A					,   """image_data/PSNR-example-base.png"""     )     )
   __lowerCAmelCase  :			Optional[int]					    =						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()


