




import numpy as np
from PIL import Image

def      lowerCAmelCase_     (					lowerCamelCase:    np.array  )   ->     np.array:


      '''simple docstring'''




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

def      lowerCAmelCase_     (					lowerCamelCase:    np.array  )   ->     np.array:


      '''simple docstring'''




      return (gray > 1_27) & (gray <= 2_55)

def      lowerCAmelCase_     (					lowerCamelCase:    np.array       ,			lowerCamelCase:    np.array  )   ->     np.array:


      '''simple docstring'''




      lowerCamelCase__ 					=			np.zeros_like(lowerCamelCase  )
      lowerCamelCase__ 					=			np.zeros(
          (image.shape[0] + kernel.shape[0] - 1, image.shape[1] + kernel.shape[1] - 1)  )

      # Copy image to padded image
      lowerCamelCase__ 					=			image

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


# kernel to be applied
__SCREAMING_SNAKE_CASE      :				Union[str, Any]				      =np.array([[0, 1, 0], [1, 1, 1], [0, 1, 0]])

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





def      lowerCAmelCase_     (					lowerCamelCase:    Optional[int]  )   ->     Union[str, Any]:


      '''simple docstring'''




      lowerCamelCase__ 					=			[7_01, 3_01, 1_32, 57, 23, 10, 4, 1]
      for gap in gaps:
            for i in range(lowerCamelCase       ,			len(lowerCamelCase  )  ):
                  lowerCamelCase__ 					=			collection[i]
                  lowerCamelCase__ 					=			i
                  while j >= gap and collection[j - gap] > insert_value:
                        lowerCamelCase__ 					=			collection[j - gap]
                        j -= gap
                  if j != i:
                        lowerCamelCase__ 					=			insert_value
      return collection


if __name__ == "__main__":
      from doctest import testmod

      testmod()
      __SCREAMING_SNAKE_CASE      :				List[Any]				      =input("""Enter numbers separated by a comma:\n""").strip()
      __SCREAMING_SNAKE_CASE      :				Dict				      =[int(item) for item in user_input.split(""",""")]
      print(shell_sort(unsorted))