






'''simple docstring'''



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



def    __UpperCAmelCase	(				SCREAMING_SNAKE_CASE__:	int,					SCREAMING_SNAKE_CASE__:	int,					SCREAMING_SNAKE_CASE__:	int,					SCREAMING_SNAKE_CASE__:	int,					SCREAMING_SNAKE_CASE__:	int,					SCREAMING_SNAKE_CASE__:	int    )  ->			np.ndarray:

   """simple docstring"""

   # prepare kernel
   # the kernel size have to be odd
   if (ksize % 2) == 0:
      __a				     =    ksize + 1
   __a				     =    np.zeros((ksize, ksize),					dtype=np.floataa    )

   # each value
   for y in range(SCREAMING_SNAKE_CASE__    ):
      for x in range(SCREAMING_SNAKE_CASE__    ):
         # distance from center
         __a				     =    x - ksize // 2
         __a				     =    y - ksize // 2

         # degree to radiant
         __a				     =    theta / 180 * np.pi
         __a				     =    np.cos(_theta    )
         __a				     =    np.sin(_theta    )

         # get kernel x
         __a				     =    cos_theta * px + sin_theta * py

         # get kernel y
         __a				     =    -sin_theta * px + cos_theta * py

         # fill kernel
         __a				     =    np.exp(
             -(_x**2 + gamma**2 * _y**2) / (2 * sigma**2)    ) * np.cos(2 * np.pi * _x / lambd + psi    )

   return gabor


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 # read original image
 __UpperCamelCase      :       Any      			=      imread("""../image_data/lena.jpg""")
 # turn image in gray scale value
 __UpperCamelCase      :       Union[str, Any]      			=      cvtColor(img, COLOR_BGR2GRAY)

 # Apply multiple Kernel to detect edges
 __UpperCamelCase      :       Tuple      			=      np.zeros(gray.shape[:2])
 for theta in [0, 30, 60, 90, 120, 150]:
  __UpperCamelCase      :       Dict      			=      gabor_filter_kernel(10, 8, theta, 10, 0, 0)
  out += filteraD(gray, CV_8UC3, kernel_aa)
 __UpperCamelCase      :       List[Any]      			=      out / out.max() * 255
 __UpperCamelCase      :       Optional[Any]      			=      out.astype(np.uinta)

 imshow("""Original""", gray)
 imshow("""Gabor filter with 20x20 mask and 6 directions""", out)

 waitKey(0)







'''simple docstring'''



from maths.prime_factors import prime_factors



def    __UpperCAmelCase	(				SCREAMING_SNAKE_CASE__:	int    )  ->			int:

   """simple docstring"""
   if not isinstance(SCREAMING_SNAKE_CASE__,					SCREAMING_SNAKE_CASE__    ):
      __a				     =    f"""Input value of [number={number}] must be an integer"""
      raise TypeError(SCREAMING_SNAKE_CASE__    )
   if number < 1:
      raise ValueError('Input must be a positive integer'    )
   return -1 if len(prime_factors(SCREAMING_SNAKE_CASE__    )    ) % 2 else 1


if __name__ == "__main__":
 import doctest

 doctest.testmod()