


from PIL import Image

def 			lowerCAmelCase__					(     a__:						Union[str, Any]			)    ->						Optional[int]:


							'''simple docstring'''





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

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


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







'''simple docstring'''






def   UpperCamelCase__ (						lowerCAmelCase    ):





      """simple docstring"""


      if not isinstance(lowerCAmelCase				,      lowerCAmelCase    ):
            raise ValueError("""Input must be an integer"""    )
      if input_num <= 0:
            raise ValueError("""Input must be positive"""    )
      return sum(
          divisor for divisor in range(1				,      input_num // 2 + 1    ) if input_num % divisor == 0    )


if __name__ == "__main__":
      import doctest

      doctest.testmod()






