
'''simple docstring'''





import numpy as np
from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey

from digital_image_processing.filters.convolve import img_convolve





def     snake_case							(						UpperCAmelCase		)->     str:







      """simple docstring"""
      __A    		=     np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]		)
      __A    		=     np.array([[1, 2, 1], [0, 0, 0], [-1, -2, -1]]		)

      __A    		=     np.abs(img_convolve(UpperCAmelCase ,					UpperCAmelCase		)		)
      __A    		=     np.abs(img_convolve(UpperCAmelCase ,					UpperCAmelCase		)		)
      # modify the pix within [0, 255]
      __A    		=     dst_x * 2_5_5 / np.max(UpperCAmelCase		)
      __A    		=     dst_y * 2_5_5 / np.max(UpperCAmelCase		)

      __A    		=     np.sqrt((np.square(UpperCAmelCase		)) + (np.square(UpperCAmelCase		))		)
      __A    		=     dst_xy * 2_5_5 / np.max(UpperCAmelCase		)
      __A    		=     dst_xy.astype(np.uinta		)

      __A    		=     np.arctana(UpperCAmelCase ,					UpperCAmelCase		)
      return dst, theta


if __name__ == "__main__":
 # read original image
 a__						:				int           =    imread("../image_data/lena.jpg")
 # turn image in gray scale value
 a__						:				Tuple           =    cvtColor(img, COLOR_BGR2GRAY)

 a__    ,						a__						:				Tuple           =    sobel_filter(gray)

 # show result images
 imshow("sobel filter", sobel_grad)
 imshow("sobel theta", sobel_theta)
 waitKey(0)








'''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()






