



'''simple docstring'''






import numpy as np
from PIL import Image


def 			snake_case_					( _lowerCAmelCase  :						np.array  )				->       np.array:
							UpperCAmelCase							,		UpperCAmelCase							,		UpperCAmelCase			:	Dict										=		rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2]
							return 0.2_9_8_9 * r + 0.5_8_7_0 * g + 0.1_1_4_0 * b


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


def 			snake_case_					( _lowerCAmelCase  :						np.array       ,				_lowerCAmelCase  :						np.array  )				->       np.array:
							UpperCAmelCase			:	Dict										=		np.zeros_like(_lowerCAmelCase  )
							UpperCAmelCase			:	Union[str, Any]										=		np.zeros(
							    (image.shape[0] + kernel.shape[0] - 1, image.shape[1] + kernel.shape[1] - 1)  )

							# Copy image to padded image
							UpperCAmelCase			:	List[Any]										=		image

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


# kernel to be applied
UpperCamelCase__:       Optional[Any]							     =      np.array([[0, 1, 0], [1, 1, 1], [0, 1, 0]])

if __name__ == "__main__":
						# read original image
						UpperCamelCase__:       Any							     =      np.array(Image.open(r"..\image_data\lena.jpg"))
						# Apply erosion operation to a binary image
						UpperCamelCase__:       Any							     =      erosion(grayabinary(rgbagray(image)), structuring_element)
						# Save the output image
						UpperCamelCase__:       List[Any]							     =      Image.fromarray(output).convert("RGB")
						pil_img.save("result_erosion.png")










'''simple docstring'''






from __future__ import annotations


def 			snake_case_					( _lowerCAmelCase  :						list[int]       ,				_lowerCAmelCase  :						int  )				->       list[int]:
							UpperCAmelCase			:	dict[int, int]										=		{}
							for index, val in enumerate(_lowerCAmelCase  ):
														UpperCAmelCase			:	Tuple										=		target - val
														if compl in chk_map:
																					return [chk_map[compl], index]
														UpperCAmelCase			:	Any										=		index
							return []


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						print(F"{two_sum([2, 7, 11, 15], 9) = }")





