






"""simple docstring"""




import math
import os

import cva
import numpy as np

UpperCamelCase											=     255.0






def 							lowerCAmelCase			(   UpperCamelCase_:				float  ,			UpperCamelCase_:				float       )							->				float:







  '''simple docstring'''







  _a					      =						np.mean((original - contrast) ** 2       )
  if mse == 0:
    return 100

  return 20 * math.logaa(PIXEL_MAX / math.sqrt(UpperCamelCase_       )       )






def 							lowerCAmelCase			(   )							->				None:







  '''simple docstring'''







  _a					      =						os.path.dirname(os.path.realpath(UpperCamelCase_       )       )
  # Loading images (original image and compressed image)
  _a					      =						cva.imread(os.path.join(UpperCamelCase_  ,			"image_data/original_image.png"       )       )
  _a					      =						cva.imread(os.path.join(UpperCamelCase_  ,			"image_data/compressed_image.png"       )  ,			1       )

  _a					      =						cva.imread(os.path.join(UpperCamelCase_  ,			"image_data/PSNR-example-base.png"       )       )
  _a					      =						cva.imread(
      os.path.join(UpperCamelCase_  ,			"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(UpperCamelCase_  ,			UpperCamelCase_       )} dB'''       )

  # # Value expected: 31.53dB (Wikipedia Example)
  print("\n-- Second Test --"       )
  print(f'''PSNR value is {peak_signal_to_noise_ratio(UpperCamelCase_  ,			UpperCamelCase_       )} dB'''       )


if __name__ == "__main__":
     main()










"""simple docstring"""




from __future__ import annotations






def 							lowerCAmelCase			(   UpperCamelCase_:				int  ,			UpperCamelCase_:				int  ,			UpperCamelCase_:				int       )							->				tuple[float, float]:







  '''simple docstring'''







  assert (
      c % greatest_common_divisor(UpperCamelCase_  ,			UpperCamelCase_       ) == 0
  )  # greatest_common_divisor(a,b) function implemented below
  ((_a)      ,						(_a)      ,						(_a))					      =						extended_gcd(UpperCamelCase_  ,			UpperCamelCase_       )  # extended_gcd(a,b) function implemented below
  _a					      =						c / d
  return (r * x, r * y)






def 							lowerCAmelCase			(   UpperCamelCase_:				int  ,			UpperCamelCase_:				int  ,			UpperCamelCase_:				int  ,			UpperCamelCase_:				int = 2       )							->				None:







  '''simple docstring'''







  ((_a)      ,						(_a))					      =						diophantine(UpperCamelCase_  ,			UpperCamelCase_  ,			UpperCamelCase_       )  # Initial value
  _a					      =						greatest_common_divisor(UpperCamelCase_  ,			UpperCamelCase_       )
  _a					      =						a // d
  _a					      =						b // d

  for i in range(UpperCamelCase_       ):
    _a					      =						xa + i * q
    _a					      =						ya - i * p
    print(UpperCamelCase_  ,			UpperCamelCase_       )






def 							lowerCAmelCase			(   UpperCamelCase_:				int  ,			UpperCamelCase_:				int       )							->				int:







  '''simple docstring'''







  if a < b:
    _a      ,						_a					      =						b, a

  while a % b != 0:
    _a      ,						_a					      =						b, a % b

  return b






def 							lowerCAmelCase			(   UpperCamelCase_:				int  ,			UpperCamelCase_:				int       )							->				tuple[int, int, int]:







  '''simple docstring'''







  assert a >= 0 and b >= 0

  if b == 0:
    _a      ,						_a      ,						_a					      =						a, 1, 0
  else:
    ((_a)      ,						(_a)      ,						(_a))					      =						extended_gcd(UpperCamelCase_  ,			a % b       )
    _a					      =						q
    _a					      =						p - q * (a // b)

  assert a % d == 0 and b % d == 0
  assert d == a * x + b * y

  return (d, x, y)


if __name__ == "__main__":
     from doctest import testmod

     testmod(name="""diophantine""", verbose=True)
     testmod(name="""diophantine_all_soln""", verbose=True)
     testmod(name="""extended_gcd""", verbose=True)
     testmod(name="""greatest_common_divisor""", verbose=True)


