




'''simple docstring'''





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


def 					UpperCamelCase_(     snake_case							:	Any							,    snake_case							:	Dict							,    snake_case							:	Optional[int]							,    snake_case							:	List[str]							,    snake_case							:	str							,    snake_case							:	Tuple					):

							'''simple docstring'''






							if (ksize % 2) == 0:
														snake_case_      =				ksize + 1
							snake_case_      =				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
																					snake_case_      =				x - ksize // 2
																					snake_case_      =				y - ksize // 2

																					# degree to radiant
																					snake_case_      =				theta / 1_8_0 * np.pi
																					snake_case_      =				np.cos(_theta					)
																					snake_case_      =				np.sin(_theta					)

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

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

																					# fill kernel
																					snake_case_      =				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
				_SCREAMING_SNAKE_CASE							:       Dict						=			imread("../image_data/lena.jpg")
				# turn image in gray scale value
				_SCREAMING_SNAKE_CASE							:       Tuple						=			cvtColor(img, COLOR_BGR2GRAY)

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

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

				waitKey(0)










'''simple docstring'''





from sympy import diff, lambdify, symbols
from sympy.functions import *  # noqa: F403


def 					UpperCamelCase_(     snake_case							:	str							,    snake_case							:	complex							,    snake_case							:	str = "x"							,    snake_case							:	float = 1_0**-1_0							,    snake_case							:	int = 1							,    ):

							'''simple docstring'''






							snake_case_      =				symbols(snake_case					)
							snake_case_      =				lambdify(snake_case							,    snake_case					)
							snake_case_      =				lambdify(snake_case							,    diff(snake_case							,    snake_case					)					)

							snake_case_      =				starting_point

							while True:
														if diff_function(snake_case					) != 0:
																					snake_case_      =				prev_guess - multiplicity * func(snake_case					) / diff_function(
																					    snake_case					)
														else:
																					raise ZeroDivisionError("Could not find root"					) from None

														# Precision is checked by comparing the difference of consecutive guesses
														if abs(next_guess - prev_guess					) < precision:
																					return next_guess

														snake_case_      =				next_guess


# Let's Execute
if __name__ == "__main__":
		# Find root of trigonometric function
		# Find value of pi
		print(F"The root of sin(x) = 0 is {newton_raphson('sin(x)', 2)}")

		# Find root of polynomial
		# Find fourth Root of 5
		print(F"The root of x**4 - 5 = 0 is {newton_raphson('x**4 -5', 0.4 +5j)}")

		# Find value of e
		print(
		    "The root of log(y) - 1 = 0 is ",
		    F"{newton_raphson('log(y) - 1', 2, variable='y')}",
		)

		# Exponential Roots
		print(
		    "The root of exp(x) - 1 = 0 is",
		    F"{newton_raphson('exp(x) - 1', 10, precision=0.0_0_5)}",
		)

		# Find root of cos(x)
		print(F"The root of cos(x) = 0 is {newton_raphson('cos(x)', 0)}")




