'''simple docstring'''

import numpy as np
from PIL import Image


def __a			(						__lowerCamelCase      :    List[Any]					)						->				Optional[Any]:
      '''simple docstring'''


      lowercase_     			=   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 __a			(						__lowerCamelCase      :    Optional[Any]					)						->				Tuple:
      '''simple docstring'''


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


def __a			(						__lowerCamelCase      :    Any			,		__lowerCamelCase      :    List[str]					)						->				Any:
      '''simple docstring'''


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

      # Copy image to padded image
      lowercase_     			=   image

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


# kernel to be applied
lowerCAmelCase_			:			int    	=   np.array([[0, 1, 0], [1, 1, 1], [0, 1, 0]])

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








'''simple docstring'''
import itertools

def     UpperCamelCase_  (						__SCREAMING_SNAKE_CASE = 1_0_0_0_0_0_0							):
    """simple docstring"""






    snake_case_			:     Optional[int]        =    [1]

    for i in itertools.count(len(__SCREAMING_SNAKE_CASE							)							):
        snake_case_			:     str        =    0
        for j in itertools.count(1							):
            snake_case_			:     List[str]        =    -1 if j % 2 == 0 else +1
            snake_case_			:     str        =    (j * j * 3 - j) // 2
            if index > i:
                break
            item += partitions[i - index] * sign
            item %= number
            index += j
            if index > i:
                break
            item += partitions[i - index] * sign
            item %= number

        if item == 0:
            return i
        partitions.append(__SCREAMING_SNAKE_CASE							)

    return 0


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  print(f"""{solution() = }""")




