


'''simple docstring'''

from PIL import Image

def 							__magic_name__(  lowerCamelCase):
						__lowerCAmelCase											= image.size
						__lowerCAmelCase											= 0
						__lowerCAmelCase											= image.load()
						for i in range(a_):
												for j in range(a_):
																		__lowerCAmelCase											= pixels[j, i]
																		mean += pixel
						mean //= width * height

						for j in range(a_):
												for i in range(a_):
																		__lowerCAmelCase											= 2_5_5 if pixels[i, j] > mean else 0
						return image


if __name__ == "__main__":
	_UpperCAmelCase :       List[Any]										= mean_threshold(Image.open("""path_to_image""").convert("""L"""))
	image.save("""output_image_path""")








"""simple docstring"""
def      __lowerCamelCase   (							a_     :		int							)			->      bool:
      if not isinstance(a_ ,   a_							):
            __SCREAMING_SNAKE_CASE   :int						=  f'''Input value of [number={number}] must be an integer'''
            raise TypeError(a_							)
      if number < 0:
            return False
      __SCREAMING_SNAKE_CASE   :Any						=  number * number
      while number > 0:
            if number % 10 != number_square % 10:
                  return False
            number //= 10
            number_square //= 10
      return True


if __name__ == "__main__":
  import doctest

  doctest.testmod()