



import math
import os

import cva
import numpy as np

A__			   = 2_55.0




def 	_UpperCAmelCase       (   snake_case			,		snake_case    ):





					"""simple docstring"""

					_lowerCAmelCase      			=					np.mean((original - contrast) ** 2    )
					if mse == 0:
										return 1_00

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




def 	_UpperCAmelCase       (   ):





					"""simple docstring"""

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

					_lowerCAmelCase      			=					cva.imread(os.path.join(_A			,		"""image_data/PSNR-example-base.png"""    )    )
					_lowerCAmelCase      			=					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()








from __future__ import annotations


def 	_UpperCAmelCase       (   snake_case    ):





					"""simple docstring"""

					_lowerCAmelCase      			=					sorted(snake_case    )
					_lowerCAmelCase      			=					len(snake_case    )
					_lowerCAmelCase      			=					length >> 1
					return (
					    (sorted_list[mid_index] + sorted_list[mid_index - 1]) / 2
					    if length % 2 == 0
					    else sorted_list[mid_index]
					)


def 	_UpperCAmelCase       (   ):





					"""simple docstring"""

					import doctest

					doctest.testmod()


if __name__ == "__main__":
	main()



