
"""simple docstring"""



from itertools import product






def 	__snake_case  (    SCREAMING_SNAKE_CASE:					int     ,  SCREAMING_SNAKE_CASE:					int						):






							"""simple docstring"""



							_lowerCAmelCase  	=			sides_number
							_lowerCAmelCase  	=			max_face_number * dice_number
							_lowerCAmelCase  	=			[0] * (max_total + 1)

							_lowerCAmelCase  	=			1
							_lowerCAmelCase  	=			range(a_     ,  max_face_number + 1						)
							for dice_numbers in product(a_     ,  repeat=a_						):
														_lowerCAmelCase  	=			sum(a_						)
														totals_frequencies[total] += 1

							return totals_frequencies






def 	__snake_case  (    ):






							"""simple docstring"""



							_lowerCAmelCase  	=			total_frequency_distribution(
							    sides_number=4     ,  dice_number=9						)
							_lowerCAmelCase  	=			total_frequency_distribution(
							    sides_number=6     ,  dice_number=6						)

							_lowerCAmelCase  	=			0
							_lowerCAmelCase  	=			9
							_lowerCAmelCase  	=			4 * 9
							_lowerCAmelCase  	=			6
							for peter_total in range(a_     ,  max_peter_total + 1						):
														peter_wins_count += peter_totals_frequencies[peter_total] * sum(
														    colin_totals_frequencies[min_colin_total:peter_total]						)

							_lowerCAmelCase  	=			(4**9) * (6**6)
							_lowerCAmelCase  	=			peter_wins_count / total_games_number

							_lowerCAmelCase  	=			round(a_     ,  ndigits=7						)

							return rounded_peter_win_probability


if __name__ == "__main__":
	print(f'{solution() = }')








"""simple docstring"""



from pathlib import Path

import numpy as np
from PIL import Image






def 	__snake_case  (    SCREAMING_SNAKE_CASE:					np.ndarray						):






							"""simple docstring"""



							_lowerCAmelCase	,		_lowerCAmelCase	,		_lowerCAmelCase  	=			rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2]
							return 0.29_89 * r + 0.58_70 * g + 0.11_40 * b






def 	__snake_case  (    SCREAMING_SNAKE_CASE:					np.ndarray						):






							"""simple docstring"""



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






def 	__snake_case  (    SCREAMING_SNAKE_CASE:					np.ndarray     ,  SCREAMING_SNAKE_CASE:					np.ndarray						):






							"""simple docstring"""



							_lowerCAmelCase  	=			np.zeros_like(SCREAMING_SNAKE_CASE						)
							_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 > 0						)
							return output


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






