



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

def       _snake_case						(						UpperCamelCase						:		int			,		UpperCamelCase						:		int			,		UpperCamelCase						:		int			,		UpperCamelCase						:		int			,		UpperCamelCase						:		int			,		UpperCamelCase						:		int						):

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

 # each value
 for y in range(UpperCamelCase						):
  for x in range(UpperCamelCase						):
   # distance from center
   UpperCAmelCase	:					int	=	x - ksize // 2
   UpperCAmelCase	:					Optional[int]	=	y - ksize // 2

   # degree to radiant
   UpperCAmelCase	:					List[str]	=	theta / 180 * np.pi
   UpperCAmelCase	:					str	=	np.cos(_theta						)
   UpperCAmelCase	:					Optional[Any]	=	np.sin(_theta						)

   # get kernel x
   UpperCAmelCase	:					List[Any]	=	cos_theta * px + sin_theta * py

   # get kernel y
   UpperCAmelCase	:					Any	=	-sin_theta * px + cos_theta * py

   # fill kernel
   UpperCAmelCase	:					Any	=	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
      A:   Any								=		imread("../image_data/lena.jpg")
      # turn image in gray scale value
      A:   Optional[int]								=		cvtColor(img, COLOR_BGR2GRAY)

      # Apply multiple Kernel to detect edges
      A:   List[str]								=		np.zeros(gray.shape[:2])
      for theta in [0, 3_0, 6_0, 9_0, 1_2_0, 1_5_0]:
            A:   List[str]								=		gabor_filter_kernel(1_0, 8, theta, 1_0, 0, 0)
            out += filteraD(gray, CV_8UC3, kernel_aa)
      A:   str								=		out / out.max() * 2_5_5
      A:   List[Any]								=		out.astype(np.uinta)

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

      waitKey(0)





"""simple docstring"""
from collections import defaultdict
from math import ceil, sqrt

def       _snake_case						(						UpperCamelCase						:		int = 1000000			,		UpperCamelCase						:		int = 10						):
 UpperCAmelCase	:					defaultdict	=	defaultdict(UpperCamelCase						)

 for outer_width in range(3			,		(t_limit // 4) + 2						):
  if outer_width * outer_width > t_limit:
   UpperCAmelCase	:					str	=	max(
       ceil(sqrt(outer_width * outer_width - t_limit						)						)			,		1						)
  else:
   UpperCAmelCase	:					Optional[Any]	=	1

  hole_width_lower_bound += (outer_width - hole_width_lower_bound) % 2

  for hole_width in range(UpperCamelCase			,		outer_width - 1			,		2						):
   count[outer_width * outer_width - hole_width * hole_width] += 1

 return sum(1 for n in count.values() if 1 <= n <= 10						)


if __name__ == "__main__":
      print(f"""{solution() = }""")
