


"""simple docstring"""





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      _snake_case						(						_snake_case				:			Optional[int] ,   _snake_case				:			Union[str, Any]			):
      lowerCAmelCase					:	Optional[int]       =   k_size // 2
      lowerCAmelCase					:	str       =   mgrid[0 - center : k_size - center, 0 - center : k_size - center]
      lowerCAmelCase					:	int       =   1 / (2 * pi * sigma) * exp(-(square(_snake_case			) + square(_snake_case			)) / (2 * square(_snake_case			))			)
      return g


def      _snake_case						(						_snake_case				:			List[Any] ,   _snake_case				:			Optional[int] ,   _snake_case				:			List[str]			):
      lowerCAmelCase					:	str       =   image.shape[0], image.shape[1]
      # dst image height and width
      lowerCAmelCase					:	Optional[Any]       =   height - k_size + 1
      lowerCAmelCase					:	Any       =   width - k_size + 1

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

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

      # reshape and get the dst image
      lowerCAmelCase					:	str       =   dot(_snake_case ,   _snake_case			).reshape(_snake_case ,   _snake_case			).astype(_snake_case			)

      return dst


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

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






"""simple docstring"""





def      _snake_case						(						_snake_case				:			float ,   _snake_case				:			list[float]			):
      if discount_rate < 0:
            raise ValueError('''Discount rate cannot be negative'''			)
      if not cash_flows:
            raise ValueError('''Cash flows list cannot be empty'''			)
      lowerCAmelCase					:	List[str]       =   sum(
          cash_flow / ((1 + discount_rate) ** i) for i, cash_flow in enumerate(_snake_case			)			)
      return round(_snake_case ,   ndigits=2			)


if __name__ == "__main__":
 import doctest

 doctest.testmod()


