





def 		A_    (					_lowerCAmelCase							,       _lowerCAmelCase					)						->			int:
 return abs(_lowerCAmelCase					) if a == 0 else greatest_common_divisor(b % a							,       _lowerCAmelCase					)



def 		A_    (					_lowerCAmelCase							,       _lowerCAmelCase					)						->			int:
 while y:  # --> when y=0 then loop will terminate and return x as final GCD.
  UpperCamelCase     ,   UpperCamelCase     : Any	     =       y, x % y
 return abs(_lowerCAmelCase					)



def 		A_    (					)						->			int:
 try:
  UpperCamelCase     : List[Any]	     =       input("Enter two integers separated by comma (,): "					).split(","					)
  UpperCamelCase     : Union[str, Any]	     =       int(nums[0]					)
  UpperCamelCase     : List[str]	     =       int(nums[1]					)
  print(
      F"""greatest_common_divisor({num_a}, {num_a}) = """
      F"""{greatest_common_divisor(_lowerCAmelCase							,       _lowerCAmelCase					)}"""					)
  print(F"""By iterative gcd({num_a}, {num_a}) = {gcd_by_iterative(_lowerCAmelCase							,       _lowerCAmelCase					)}"""					)
 except (IndexError, UnboundLocalError, ValueError):
  print("Wrong input"					)


if __name__ == "__main__":
    main()







from pathlib import Path

import numpy as np
from PIL import Image



def 		A_    (					_lowerCAmelCase					)						->			np.ndarray:
 UpperCamelCase     ,   UpperCamelCase     ,   UpperCamelCase     : Optional[Any]	     =       rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2]
 return 0.2_989 * r + 0.5_870 * g + 0.1_140 * b



def 		A_    (					_lowerCAmelCase					)						->			np.ndarray:
 return (gray > 127) & (gray <= 255)



def 		A_    (					_lowerCAmelCase							,       _lowerCAmelCase					)						->			np.ndarray:
 UpperCamelCase     : Dict	     =       np.zeros_like(_lowerCAmelCase					)
 UpperCamelCase     : List[str]	     =       np.zeros(
     (image.shape[0] + kernel.shape[0] - 1, image.shape[1] + kernel.shape[1] - 1)					)

 # Copy image to padded image
 UpperCamelCase     : Tuple	     =       image

 # Iterate over image & apply kernel
 for x in range(image.shape[1]					):
  for y in range(image.shape[0]					):
   UpperCamelCase     : List[str]	     =       (
       kernel * image_padded[y : y + kernel.shape[0], x : x + kernel.shape[1]]
   ).sum()
   UpperCamelCase     : int	     =       int(summation > 0					)
 return output


if __name__ == "__main__":
    # read original image
    __lowerCamelCase	:					int			  =					Path(__file__).resolve().parent / """image_data""" / """lena.jpg"""
    __lowerCamelCase	:					Tuple			  =					np.array(Image.open(lena_path))
    # kernel to be applied
    __lowerCamelCase	:					Optional[Any]			  =					np.array([[0, 1, 0], [1, 1, 1], [0, 1, 0]])
    __lowerCamelCase	:					Union[str, Any]			  =					dilation(gray_to_binary(rgb_to_gray(lena)), structuring_element)
    # Save the output image
    __lowerCamelCase	:					Any			  =					Image.fromarray(output).convert("""RGB""")
    pil_img.save("""result_dilation.png""")
