
from itertools import product

from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros



def        UpperCamelCase    (							lowerCAmelCase__ ,			lowerCAmelCase__		):
					'''simple docstring'''
					lowercase							=						k_size // 2
					lowercase	,						lowercase							=						mgrid[0 - center : k_size - center, 0 - center : k_size - center]
					lowercase							=						1 / (2 * pi * sigma) * exp(-(square(lowerCAmelCase__		) + square(lowerCAmelCase__		)) / (2 * square(lowerCAmelCase__		))		)
					return g



def        UpperCamelCase    (							lowerCAmelCase__ ,			lowerCAmelCase__ ,			lowerCAmelCase__		):
					'''simple docstring'''
					lowercase	,						lowercase							=						image.shape[0], image.shape[1]
					# dst image height and width
					lowercase							=						height - k_size + 1
					lowercase							=						width - k_size + 1

					# im2col, turn the k_size*k_size pixels into a row and np.vstack all rows
					lowercase							=						zeros((dst_height * dst_width, k_size * k_size)		)
					lowercase							=						0
					for i, j in product(range(lowerCAmelCase__		) ,			range(lowerCAmelCase__		)		):
										lowercase							=						ravel(image[i : i + k_size, j : j + k_size]		)
										lowercase							=						window
										row += 1

					#  turn the kernel into shape(k*k, 1)
					lowercase							=						gen_gaussian_kernel(lowerCAmelCase__ ,			lowerCAmelCase__		)
					lowercase							=						ravel(lowerCAmelCase__		)

					# reshape and get the dst image
					lowercase							=						dot(lowerCAmelCase__ ,			lowerCAmelCase__		).reshape(lowerCAmelCase__ ,			lowerCAmelCase__		).astype(lowerCAmelCase__		)

					return dst


if __name__ == "__main__":
							# read original image
							lowercase__		:int   =    imread(r"../image_data/lena.jpg")
							# turn image in gray scale value
							lowercase__		:Any   =    cvtColor(img, COLOR_BGR2GRAY)

							# get values with two different mask size
							lowercase__		:Optional[Any]   =    gaussian_filter(gray, 3, sigma=1)
							lowercase__		:List[Any]   =    gaussian_filter(gray, 5, sigma=0.8)

							# show result images
							imshow("gaussian filter with 3x3 mask", gaussianaxa)
							imshow("gaussian filter with 5x5 mask", gaussianaxa)
							waitKey()






from functools import lru_cache



@lru_cache
def        UpperCamelCase    (							lowerCAmelCase__		):
					'''simple docstring'''
					if num < 0:
										raise ValueError('''Number should not be negative.'''		)

					return 1 if num in (0, 1) else num * factorial(num - 1		)


if __name__ == "__main__":
							import doctest

							doctest.testmod()




