'''simple docstring'''

from __future__ import annotations

import random
class 							lowercase_    :
    a_             =   6







    def __init__(	self				)				->       int:





     """simple docstring"""

     UpperCAmelCase_				       =					list(range(1       ,     Dice.NUM_SIDES + 1				)				)







    def   lowerCamelCase_    (	self				)				->       Optional[int]:





     """simple docstring"""

     return random.choice(self.sides				)



def lowerCamelCase__						(       A_       ,			A_ = 2       ):
 UpperCAmelCase_				       =					[Dice() for i in range(A_       )]
 UpperCAmelCase_				       =					[0] * (len(A_       ) * Dice.NUM_SIDES + 1)
 for _ in range(A_       ):
  count_of_sum[sum(dice.roll() for dice in dices       )] += 1
 UpperCAmelCase_				       =					[round((count * 100) / num_throws       ,			2       ) for count in count_of_sum]
 return probability[num_dice:]  # remove probability of sums that never appear


if __name__ == "__main__":
      import doctest

      doctest.testmod()

'''simple docstring'''

import numpy as np
from PIL import Image



def lowerCamelCase__						(       A_       ):
 UpperCAmelCase_       ,       UpperCAmelCase_       ,       UpperCAmelCase_				       =					rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2]
 return 0.2989 * r + 0.5870 * g + 0.1140 * b



def lowerCamelCase__						(       A_       ):
 return (gray > 127) & (gray <= 255)



def lowerCamelCase__						(       A_       ,			A_       ):
 UpperCAmelCase_				       =					np.zeros_like(A_       )
 UpperCAmelCase_				       =					np.zeros(
     (image.shape[0] + kernel.shape[0] - 1, image.shape[1] + kernel.shape[1] - 1)       )

 # Copy image to padded image
 UpperCAmelCase_				       =					image

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


# kernel to be applied
__snake_case       :   List[str]  		=    np.array([[0, 1, 0], [1, 1, 1], [0, 1, 0]])

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