


'''simple docstring'''



import colorsys

from PIL import Image  # type: ignore




def 			_a			(		_lowercase      :			float    ,      _lowercase      :			float    ,      _lowercase      :			int						):





     '''simple docstring'''






     __UpperCAmelCase			:				Optional[int]													=    x
     __UpperCAmelCase			:				Dict													=    y
     for step in range(_lowercase						):  # noqa: B007
          __UpperCAmelCase			:				List[Any]													=    a * a - b * b + x
          __UpperCAmelCase			:				Any													=    2 * a * b + y
          __UpperCAmelCase			:				List[Any]													=    a_new

          # divergence happens for all complex number with an absolute value
          # greater than 4
          if a * a + b * b > 4:
               break
     return step / (max_step - 1)




def 			_a			(		_lowercase      :			float						):





     '''simple docstring'''






     if distance == 1:
          return (0, 0, 0)
     else:
          return (255, 255, 255)




def 			_a			(		_lowercase      :			float						):





     '''simple docstring'''






     if distance == 1:
          return (0, 0, 0)
     else:
          return tuple(round(i * 255						) for i in colorsys.hsv_to_rgb(_lowercase    ,      1    ,      1						)						)




def 			_a			(		_lowercase      :			int = 800    ,      _lowercase      :			int = 600    ,      _lowercase      :			float = -0.6    ,      _lowercase      :			float = 0    ,      _lowercase      :			float = 3.2    ,      _lowercase      :			int = 50    ,      _lowercase      :			bool = True    ,      ):





     '''simple docstring'''






     __UpperCAmelCase			:				int													=    Image.new('''RGB'''    ,      (image_width, image_height)						)
     __UpperCAmelCase			:				int													=    img.load()

     # loop through the image-coordinates
     for image_x in range(_lowercase						):
          for image_y in range(_lowercase						):
               # determine the figure-coordinates based on the image-coordinates
               __UpperCAmelCase			:				Union[str, Any]													=    figure_width / image_width * image_height
               __UpperCAmelCase			:				Optional[Any]													=    figure_center_x + (image_x / image_width - 0.5) * figure_width
               __UpperCAmelCase			:				Optional[int]													=    figure_center_y + (image_y / image_height - 0.5) * figure_height

               __UpperCAmelCase			:				int													=    get_distance(_lowercase    ,      _lowercase    ,      _lowercase						)

               # color the corresponding pixel based on the selected coloring-function
               if use_distance_color_coding:
                    __UpperCAmelCase			:				str													=    get_color_coded_rgb(_lowercase						)
               else:
                    __UpperCAmelCase			:				str													=    get_black_and_white_rgb(_lowercase						)

     return img


if __name__ == "__main__":
      import doctest

      doctest.testmod()

      # colored version, full figure
      __UpperCAmelCase    :List[str]				       =     get_image()

      # uncomment for colored version, different section, zoomed in
      # img = get_image(figure_center_x = -0.6, figure_center_y = -0.4,
      # figure_width = 0.8)

      # uncomment for black and white version, full figure
      # img = get_image(use_distance_color_coding = False)

      # uncomment to save the image
      # img.save("mandelbrot.png")

      img.show()



'''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 			_a			(		_lowercase      :			Optional[Any]    ,      _lowercase      :			List[Any]						):





     '''simple docstring'''






     __UpperCAmelCase			:				Dict													=    k_size // 2
     __UpperCAmelCase							,     __UpperCAmelCase			:				Any													=    mgrid[0 - center : k_size - center, 0 - center : k_size - center]
     __UpperCAmelCase			:				Optional[int]													=    1 / (2 * pi * sigma) * exp(-(square(_lowercase						) + square(_lowercase						)) / (2 * square(_lowercase						))						)
     return g




def 			_a			(		_lowercase      :			str    ,      _lowercase      :			List[str]    ,      _lowercase      :			Optional[Any]						):





     '''simple docstring'''






     __UpperCAmelCase							,     __UpperCAmelCase			:				Any													=    image.shape[0], image.shape[1]
     # dst image height and width
     __UpperCAmelCase			:				Any													=    height - k_size + 1
     __UpperCAmelCase			:				str													=    width - k_size + 1

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

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

     # reshape and get the dst image
     __UpperCAmelCase			:				Optional[int]													=    dot(_lowercase    ,      _lowercase						).reshape(_lowercase    ,      _lowercase						).astype(_lowercase						)

     return dst


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

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