


from PIL import Image





def 						_lowerCAmelCase							(     _lowerCAmelCase			)    ->						Image:


						'''simple docstring'''






						__snake_case		,       __snake_case				=		image.size
						__snake_case				=		0
						__snake_case				=		image.load()
						for i in range(_lowerCAmelCase			):
												for j in range(_lowerCAmelCase			):
																		__snake_case				=		pixels[j, i]
																		mean += pixel
						mean //= width * height

						for j in range(_lowerCAmelCase			):
												for i in range(_lowerCAmelCase			):
																		__snake_case				=		255 if pixels[i, j] > mean else 0
						return image


if __name__ == "__main__":
	A				:       Union[str, Any]      =  mean_threshold(Image.open('path_to_image').convert('L'))
	image.save('output_image_path')









from __future__ import annotations





def 						_lowerCAmelCase							(     _lowerCAmelCase			)    ->						list[int]:


						'''simple docstring'''






						__snake_case				=		2
						__snake_case				=		[]
						while i * i <= n:
												if n % i:
																		i += 1
												else:
																		n //= i
																		factors.append(_lowerCAmelCase			)
						if n > 1:
												factors.append(_lowerCAmelCase			)
						return factors


if __name__ == "__main__":
	import doctest

	doctest.testmod()





