




'''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 		a_( lowerCamelCase      )				->Dict:






       '''simple docstring'''




       lowercase  :		Union[str, Any]						=      np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]      )
       lowercase  :		Optional[int]						=      np.array([[1, 2, 1], [0, 0, 0], [-1, -2, -1]]      )

       lowercase  :		Tuple						=      np.abs(img_convolve(lowerCamelCase   ,				lowerCamelCase      )      )
       lowercase  :		Tuple						=      np.abs(img_convolve(lowerCamelCase   ,				lowerCamelCase      )      )
       # modify the pix within [0, 255]
       lowercase  :		Union[str, Any]						=      dst_x * 255 / np.max(lowerCamelCase      )
       lowercase  :		Optional[int]						=      dst_y * 255 / np.max(lowerCamelCase      )

       lowercase  :		Dict						=      np.sqrt((np.square(lowerCamelCase      )) + (np.square(lowerCamelCase      ))      )
       lowercase  :		Dict						=      dst_xy * 255 / np.max(lowerCamelCase      )
       lowercase  :		Tuple						=      dst_xy.astype(np.uinta      )

       lowercase  :		Any						=      np.arctana(lowerCamelCase   ,				lowerCamelCase      )
       return dst, theta


if __name__ == "__main__":
      # read original image
      lowercase	:      List[str]       	=       imread('''../image_data/lena.jpg''')
      # turn image in gray scale value
      lowercase	:      str       	=       cvtColor(img, COLOR_BGR2GRAY)

      lowercase	:      Union[str, Any]       	=       sobel_filter(gray)

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










'''simple docstring'''






import math
from timeit import timeit




def 		a_( lowerCamelCase      )				->int:






       '''simple docstring'''




       lowercase  :		Dict						=      0
       lowercase  :		Union[str, Any]						=      abs(lowerCamelCase      )
       while True:
              lowercase  :		List[Any]						=      n // 10
              digits += 1
              if n == 0:
                     break
       return digits




def 		a_( lowerCamelCase      )				->int:






       '''simple docstring'''




       return 1 if n == 0 else math.floor(math.log(abs(lowerCamelCase      )   ,				10      ) + 1      )




def 		a_( lowerCamelCase      )				->int:






       '''simple docstring'''




       return len(str(abs(lowerCamelCase      )      )      )




def 		a_( )				->None:






       '''simple docstring'''




       from collections.abc import Callable

       def benchmark_a_function(lowerCamelCase   ,				lowerCamelCase      ) -> None:
              lowercase  :		str						=      f"""{func.__name__}({value})"""
              lowercase  :		Optional[Any]						=      timeit(f"""__main__.{call}"""   ,				setup='''import __main__'''      )
              print(f"""{call}: {func(lowerCamelCase      )} -- {timing} seconds"""      )

       for value in (26_2144, 1125_8999_0684_2624, 126_7650_6002_2822_9401_4967_0320_5376):
              for func in (num_digits, num_digits_fast, num_digits_faster):
                     benchmark_a_function(lowerCamelCase   ,				lowerCamelCase      )
              print()


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      benchmark()




