'''simple docstring'''


def    _lowerCamelCase       ( lowerCamelCase_   :				int      ,	lowerCamelCase_   :				int = 1000  ):



     """simple docstring"""





     if (not isinstance(lowerCamelCase_      ,	lowerCamelCase_  )) or (digit_position <= 0):
          raise ValueError('Digit position must be a positive integer'  )
     elif (not isinstance(lowerCamelCase_      ,	lowerCamelCase_  )) or (precision < 0):
          raise ValueError('Precision must be a nonnegative integer'  )

     # compute an approximation of (16 ** (n - 1)) * pi whose fractional part is mostly
     # accurate
     UpperCAmelCase_				:  Tuple  = (
         4 * _subsum(lowerCamelCase_      ,	1      ,	lowerCamelCase_  )
         - 2 * _subsum(lowerCamelCase_      ,	4      ,	lowerCamelCase_  )
         - _subsum(lowerCamelCase_      ,	5      ,	lowerCamelCase_  )
         - _subsum(lowerCamelCase_      ,	6      ,	lowerCamelCase_  )
     )

     # return the first hex digit of the fractional part of the result
     return hex(int((sum_result % 1) * 16  )  )[2:]


def    _lowerCamelCase       ( lowerCamelCase_   :				int      ,	lowerCamelCase_   :				int      ,	lowerCamelCase_   :				int  ):



     """simple docstring"""





     UpperCAmelCase_				:  Tuple  = 0.0
     for sum_index in range(digit_pos_to_extract + precision  ):
          UpperCAmelCase_				:  List[str]  = 8 * sum_index + denominator_addend
          if sum_index < digit_pos_to_extract:
               # if the exponential term is an integer and we mod it by the denominator
               # before dividing, only the integer part of the sum will change;
               # the fractional part will not
               UpperCAmelCase_				:  Any  = pow(
                   16      ,	digit_pos_to_extract - 1 - sum_index      ,	lowerCamelCase_  )
          else:
               UpperCAmelCase_				:  Optional[int]  = pow(16      ,	digit_pos_to_extract - 1 - sum_index  )
          total += exponential_term / denominator
     return total


if __name__ == "__main__":
 import doctest

 doctest.testmod()







'''simple docstring'''
import numpy as np
from PIL import Image







def 				__UpperCamelCase (					__UpperCAmelCase  :					np.array			)							->	np.array:
  lowercase				,      lowercase				,      lowercase				:							Dict									=   rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2]
  return 0.2989 * r + 0.5870 * g + 0.1140 * b







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







def 				__UpperCamelCase (					__UpperCAmelCase  :					np.array ,   __UpperCAmelCase  :					np.array			)							->	np.array:
  lowercase				:							str									=   np.zeros_like(__UpperCAmelCase			)
  lowercase				:							Tuple									=   np.zeros(
      (image.shape[0] + kernel.shape[0] - 1, image.shape[1] + kernel.shape[1] - 1)			)

  # Copy image to padded image
  lowercase				:							int									=   image

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


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

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