
'''simple docstring'''





def  UpperCamelCase					(							lowerCAmelCase__	):
					'''simple docstring'''
					return 10 - x * x



def  UpperCamelCase					(							lowerCAmelCase__				,    lowerCAmelCase__	):
					'''simple docstring'''
					# Bolzano theory in order to find if there is a root between a and b
					if equation(lowerCAmelCase__	) * equation(lowerCAmelCase__	) >= 0:
										raise ValueError('''Wrong space!'''	)

					lowercase					=		a
					while (b - a) >= 0.01:
										# Find middle point
										lowercase					=		(a + b) / 2
										# Check if middle point is root
										if equation(lowerCAmelCase__	) == 0.0:
															break
										# Decide the side to repeat the steps
										if equation(lowerCAmelCase__	) * equation(lowerCAmelCase__	) < 0:
															lowercase					=		c
										else:
															lowercase					=		c
					return c


if __name__ == "__main__":
							import doctest

							doctest.testmod()

							print(bisection(-2, 5))
							print(bisection(0, 6))






from pathlib import Path

import numpy as np
from PIL import Image



def  UpperCamelCase					(							lowerCAmelCase__	):
					'''simple docstring'''
					lowercase			,		lowercase			,		lowercase					=		rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2]
					return 0.29_89 * r + 0.58_70 * g + 0.11_40 * b



def  UpperCamelCase					(							lowerCAmelCase__	):
					'''simple docstring'''
					return (gray > 127) & (gray <= 255)



def  UpperCamelCase					(							lowerCAmelCase__				,    lowerCAmelCase__	):
					'''simple docstring'''
					lowercase					=		np.zeros_like(lowerCAmelCase__	)
					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 > 0	)
					return output


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




