
'''simple docstring'''





a__						:				int           =    1_0_0_0





def     snake_case							(						UpperCAmelCase		)->     float:







      """simple docstring"""
      return x * x





def     snake_case							(						UpperCAmelCase ,					UpperCAmelCase ,					UpperCAmelCase ,					UpperCAmelCase = 4		)->     float:







      """simple docstring"""
      assert callable(
          UpperCAmelCase		), f'the function(object) passed should be callable your input : {function}'
      assert isinstance(UpperCAmelCase ,					(float, int)		), f'a should be float or integer your input : {a}'
      assert isinstance(function(UpperCAmelCase		) ,					(float, int)		), (
          "the function should return integer or float return type of your function, "
          f'{type(UpperCAmelCase		)}'
      )
      assert isinstance(UpperCAmelCase ,					(float, int)		), f'b should be float or integer your input : {b}'
      assert (
          isinstance(UpperCAmelCase ,					UpperCAmelCase		) and precision > 0
      ), f'precision should be positive integer your input : {precision}'

      # just applying the formula of simpson for approximate integration written in
      # mentioned article in first comment of this file and above this function

      __A    		=     (b - a) / N_STEPS
      __A    		=     function(UpperCAmelCase		) + function(UpperCAmelCase		)

      for i in range(1 ,					UpperCAmelCase		):
            __A    		=     a + h * i
            result += function(UpperCAmelCase		) * (4 if i % 2 else 2)

      result *= h / 3
      return round(UpperCAmelCase ,					UpperCAmelCase		)


if __name__ == "__main__":
 import doctest

 doctest.testmod()








'''simple docstring'''





import math
import os

import cva
import numpy as np

a__						:				List[Any]           =    255.0





def     snake_case							(						UpperCAmelCase ,					UpperCAmelCase		)->     float:







      """simple docstring"""
      __A    		=     np.mean((original - contrast) ** 2		)
      if mse == 0:
            return 1_0_0

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





def     snake_case							(						)->     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()






