"""simple docstring"""




from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
from numpy import divide, inta, multiply, ravel, sort, zeros_like



def 				__a       (			_lowercase							, _lowercase=3						):







					"""simple docstring"""





					lowerCamelCase__		:   List[Any]  				=					int(mask / 2						)
					# copy image size
					lowerCamelCase__		:   int  				=					zeros_like(_lowercase						)
					for i in range(_lowercase							, gray_img.shape[0] - bd						):
										for j in range(_lowercase							, gray_img.shape[1] - bd						):
															# get mask according with mask
															lowerCamelCase__		:   Dict  				=					ravel(gray_img[i - bd : i + bd + 1, j - bd : j + bd + 1]						)
															# calculate mask median
															lowerCamelCase__		:   List[str]  				=					sort(_lowercase						)[inta(divide((multiply(_lowercase							, _lowercase						))							, 2						) + 1						)]
															lowerCamelCase__		:   Tuple  				=					median
					return median_img


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

					# get values with two different mask size
					UpperCAmelCase       :    Optional[int]									=			median_filter(gray, 3)
					UpperCAmelCase       :    List[Any]									=			median_filter(gray, 5)

					# show result images
					imshow("median filter with 3x3 mask", medianaxa)
					imshow("median filter with 5x5 mask", medianaxa)
					waitKey(0)







"""simple docstring"""




from collections.abc import Callable

UpperCAmelCase       :    Optional[int]									=			Callable[[float], float]  # type alias for a real -> real function



def 				__a       (			_lowercase							, _lowercase							, _lowercase							, ):







					"""simple docstring"""





					lowerCamelCase__		:   Tuple  				=					float(_lowercase						)
					while True:
										try:
															lowerCamelCase__		:   str  				=					prev_guess - function(_lowercase						) / derivative(_lowercase						)
										except ZeroDivisionError:
															raise ZeroDivisionError('''Could not find root'''						) from None
										if abs(prev_guess - next_guess						) < 10**-5:
															return next_guess
										lowerCamelCase__		:   List[str]  				=					next_guess



def 				__a       (			_lowercase						):







					"""simple docstring"""





					return (x**3) - (2 * x) - 5



def 				__a       (			_lowercase						):







					"""simple docstring"""





					return 3 * (x**2) - 2


if __name__ == "__main__":
					print(newton(f, fa, 3))






