"""simple docstring"""




from pathlib import Path

import numpy as np
from PIL import Image





def 							SCREAMING_SNAKE_CASE  (    _lowerCamelCase		: List[Any]			) ->   np.ndarray:
  _lowerCAmelCase    ,			_lowerCAmelCase    ,			_lowerCAmelCase		: str						    =  rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2]
  return 0.29_89 * r + 0.58_70 * g + 0.11_40 * b





def 							SCREAMING_SNAKE_CASE  (    _lowerCamelCase		: Dict			) ->   np.ndarray:
  return (gray > 127) & (gray <= 255)





def 							SCREAMING_SNAKE_CASE  (    _lowerCamelCase		: Optional[int]    ,_lowerCamelCase		: Union[str, Any]			) ->   np.ndarray:
  _lowerCAmelCase		: Optional[Any]						    =  np.zeros_like(__UpperCamelCase			)
  _lowerCAmelCase		: Union[str, Any]						    =  np.zeros(
      (image.shape[0] + kernel.shape[0] - 1, image.shape[1] + kernel.shape[1] - 1)			)

  # Copy image to padded image
  _lowerCAmelCase		: str						    =  image

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


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





"""simple docstring"""




def 							SCREAMING_SNAKE_CASE  (    _lowerCamelCase		: int			) ->   bool:
  return sum(i for i in range(1    ,number // 2 + 1			) if number % i == 0			) == number


if __name__ == "__main__":
     print('Program to check whether a number is a Perfect number or not...')
     _a   :	int 					=     int(input('Enter number: ').strip())
     print(F"""{number} is {"" if perfect(number) else "not "}a Perfect Number.""")




