


def 					lowerCamelCase_   (	_a	):




		"""simple docstring"""






		lowerCAmelCase__       :      str   					= []
		if len(_a	) == 1:
				return [nums.copy()]
		for _ in range(len(_a	)	):
				lowerCAmelCase__       :      Tuple   					= nums.pop(0	)
				lowerCAmelCase__       :      Optional[int]   					= permute(_a	)
				for perm in permutations:
						perm.append(_a	)
				result.extend(_a	)
				nums.append(_a	)
		return result






def 					lowerCamelCase_   (	_a	):




		"""simple docstring"""






		def backtrack(_a	):
				if start == len(_a	) - 1:
						output.append(nums[:]	)
				else:
						for i in range(_a     ,       len(_a	)	):
								lowerCAmelCase__					,     lowerCAmelCase__       :      Optional[Any]   					= nums[i], nums[start]
								backtrack(start + 1	)
								lowerCAmelCase__					,     lowerCAmelCase__       :      Any   					= nums[i], nums[start]  # backtrack

		lowerCAmelCase__       :      Dict   					= []
		backtrack(0	)
		return output


if __name__ == "__main__":
		import doctest

		# use res to print the data in permute2 function
		lowerCamelCase						=		permutea([1, 2, 3])
		print(res)
		doctest.testmod()








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 					lowerCamelCase_   (	_a     ,       _a	):




		"""simple docstring"""






		lowerCAmelCase__       :      List[Any]   					= k_size // 2
		lowerCAmelCase__					,     lowerCAmelCase__       :      Union[str, Any]   					= mgrid[0 - center : k_size - center, 0 - center : k_size - center]
		lowerCAmelCase__       :      str   					= 1 / (2 * pi * sigma) * exp(-(square(_a	) + square(_a	)) / (2 * square(_a	))	)
		return g






def 					lowerCamelCase_   (	_a     ,       _a     ,       _a	):




		"""simple docstring"""






		lowerCAmelCase__					,     lowerCAmelCase__       :      int   					= image.shape[0], image.shape[1]
		# dst image height and width
		lowerCAmelCase__       :      Any   					= height - k_size + 1
		lowerCAmelCase__       :      Tuple   					= width - k_size + 1

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

		#  turn the kernel into shape(k*k, 1)
		lowerCAmelCase__       :      List[Any]   					= gen_gaussian_kernel(_a     ,       _a	)
		lowerCAmelCase__       :      str   					= ravel(_a	)

		# reshape and get the dst image
		lowerCAmelCase__       :      int   					= dot(_a     ,       _a	).reshape(_a     ,       _a	).astype(_a	)

		return dst


if __name__ == "__main__":
		# read original image
		lowerCamelCase						=		imread(R'''../image_data/lena.jpg''')
		# turn image in gray scale value
		lowerCamelCase						=		cvtColor(img, COLOR_BGR2GRAY)

		# get values with two different mask size
		lowerCamelCase						=		gaussian_filter(gray, 3, sigma=1)
		lowerCamelCase						=		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()




