






"""simple docstring"""



import math
import os

import cva
import numpy as np

__A		:	int      =		255.0



def 						lowercase   (    __snake_case    :			float		, __snake_case    :			float     ):
		lowercase_			:			Any								=       np.mean((original - contrast) ** 2     )
		if mse == 0:
				return 1_0_0

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



def 						lowercase   (    ):
		lowercase_			:			Any								=       os.path.dirname(os.path.realpath(__snake_case     )     )
		# Loading images (original image and compressed image)
		lowercase_			:			Union[str, Any]								=       cva.imread(os.path.join(__snake_case		, '''image_data/original_image.png'''     )     )
		lowercase_			:			List[Any]								=       cva.imread(os.path.join(__snake_case		, '''image_data/compressed_image.png'''     )		, 1     )

		lowercase_			:			Tuple								=       cva.imread(os.path.join(__snake_case		, '''image_data/PSNR-example-base.png'''     )     )
		lowercase_			:			List[str]								=       cva.imread(
		    os.path.join(__snake_case		, '''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(__snake_case		, __snake_case     )} dB'''     )

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


if __name__ == "__main__":
						main()











"""simple docstring"""



import math
import os

import cva
import numpy as np

__A		:	int      =		255.0



def 						lowercase   (    __snake_case    :			float		, __snake_case    :			float     ):
		lowercase_			:			Any								=       np.mean((original - contrast) ** 2     )
		if mse == 0:
				return 1_0_0

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



def 						lowercase   (    ):
		lowercase_			:			Any								=       os.path.dirname(os.path.realpath(__snake_case     )     )
		# Loading images (original image and compressed image)
		lowercase_			:			Union[str, Any]								=       cva.imread(os.path.join(__snake_case		, '''image_data/original_image.png'''     )     )
		lowercase_			:			List[Any]								=       cva.imread(os.path.join(__snake_case		, '''image_data/compressed_image.png'''     )		, 1     )

		lowercase_			:			Tuple								=       cva.imread(os.path.join(__snake_case		, '''image_data/PSNR-example-base.png'''     )     )
		lowercase_			:			List[str]								=       cva.imread(
		    os.path.join(__snake_case		, '''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(__snake_case		, __snake_case     )} dB'''     )

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


if __name__ == "__main__":
						main()



