


"""simple docstring"""
from pathlib import Path

import numpy as np
from PIL import Image






def 		lowercase							(     _snake_case						:      np.ndarray     )     ->np.ndarray:
	"""simple docstring"""





	__snake_case	,							__snake_case	,							__snake_case	:						Optional[Any]						=				rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2]
	return 0.2989 * r + 0.5870 * g + 0.1140 * b






def 		lowercase							(     _snake_case						:      np.ndarray     )     ->np.ndarray:
	"""simple docstring"""





	return (gray > 127) & (gray <= 255)






def 		lowercase							(     _snake_case						:      np.ndarray     ,   _snake_case						:      np.ndarray     )     ->np.ndarray:
	"""simple docstring"""





	__snake_case	:						Union[str, Any]						=				np.zeros_like(_snake_case     )
	__snake_case	:						List[Any]						=				np.zeros(
	    (image.shape[0] + kernel.shape[0] - 1, image.shape[1] + kernel.shape[1] - 1)     )

	# Copy image to padded image
	__snake_case	:						Tuple						=				image

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


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










'''simple docstring'''





_UpperCamelCase											=						tuple[float, float, float]
_UpperCamelCase											=						tuple[float, float, float]

def        a_     (							_lowerCAmelCase       ,_lowerCAmelCase       )      ->      Vectorad:
  __lowerCamelCase       :       Any           = end_pointa[0] - end_pointa[0]
  __lowerCamelCase       :       str           = end_pointa[1] - end_pointa[1]
  __lowerCamelCase       :       Tuple           = end_pointa[2] - end_pointa[2]
  return (x, y, z)

def        a_     (							_lowerCAmelCase       ,_lowerCAmelCase       )      ->      Vectorad:
  __lowerCamelCase       :       List[str]           = ab[1] * ac[2] - ab[2] * ac[1]  # *i
  __lowerCamelCase       :       Dict           = (ab[0] * ac[2] - ab[2] * ac[0]) * -1  # *j
  __lowerCamelCase       :       List[Any]           = ab[0] * ac[1] - ab[1] * ac[0]  # *k
  return (x, y, z)

def        a_     (							_lowerCAmelCase       ,_lowerCAmelCase       )      ->      bool:
  return tuple(round(_lowerCAmelCase       ,_lowerCAmelCase       ) for x in vector       ) == (0, 0, 0)


def        a_     (							_lowerCAmelCase       ,_lowerCAmelCase       ,_lowerCAmelCase       ,_lowerCAmelCase = 10       )      ->      bool:
  __lowerCamelCase       :       str           = create_vector(_lowerCAmelCase       ,_lowerCAmelCase       )
  __lowerCamelCase       :       Dict           = create_vector(_lowerCAmelCase       ,_lowerCAmelCase       )
  return is_zero_vector(get_ad_vectors_cross(_lowerCAmelCase       ,_lowerCAmelCase       )       ,_lowerCAmelCase       )






