





"""simple docstring"""






from PIL import Image

def      __A   (      a_    :Image)		->		Image:
				__a							,    __a			:    Tuple      							=	image.size
				__a			:    Optional[Any]      							=	0
				__a			:    Dict      							=	image.load()
				for i in range(a_):
								for j in range(a_):
												__a			:    Optional[Any]      							=	pixels[j, i]
												mean += pixel
				mean //= width * height

				for j in range(a_):
								for i in range(a_):
												__a			:    Optional[Any]      							=	2_55 if pixels[i, j] > mean else 0
				return image


if __name__ == "__main__":
		A			      =	mean_threshold(Image.open('''path_to_image''').convert('''L'''))
		image.save('''output_image_path''')

def 						SCREAMING_SNAKE_CASE__     (   __lowerCAmelCase				):
    if any(not isinstance(__lowerCAmelCase     ,		__lowerCAmelCase				) or x < 0 for x in sequence				):
        raise TypeError("Sequence must be list of non-negative integers"				)
    for _ in range(len(__lowerCAmelCase				)				):
        for i, (rod_upper, rod_lower) in enumerate(zip(__lowerCAmelCase     ,		sequence[1:]				)				):
            if rod_upper > rod_lower:
                sequence[i] -= rod_upper - rod_lower
                sequence[i + 1] += rod_upper - rod_lower
    return sequence


if __name__ == "__main__":
     assert bead_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5]
     assert bead_sort([7, 9, 4, 3, 5]) == [3, 4, 5, 7, 9]



