

'''simple docstring'''

from PIL import Image




def 				UpperCamelCase(					UpperCAmelCase_     ):
 UpperCAmelCase ,			UpperCAmelCase	:     int						 =			image.size
 UpperCAmelCase	:     Tuple						 =			0
 UpperCAmelCase	:     Tuple						 =			image.load()
 for i in range(UpperCAmelCase_     ):
  for j in range(UpperCAmelCase_     ):
   UpperCAmelCase	:     Union[str, Any]						 =			pixels[j, i]
   mean += pixel
 mean //= width * height

 for j in range(UpperCAmelCase_     ):
  for i in range(UpperCAmelCase_     ):
   UpperCAmelCase	:     Dict						 =			2_55 if pixels[i, j] > mean else 0
 return image


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







'''simple docstring'''

def 				UpperCamelCase(					UpperCAmelCase_  ,	UpperCAmelCase_     ):
 if b == 0:
  return 1
 if (b % 2) == 0:
  return actual_power(UpperCAmelCase_  ,	int(b / 2     )     ) * actual_power(UpperCAmelCase_  ,	int(b / 2     )     )
 else:
  return a * actual_power(UpperCAmelCase_  ,	int(b / 2     )     ) * actual_power(UpperCAmelCase_  ,	int(b / 2     )     )




def 				UpperCamelCase(					UpperCAmelCase_  ,	UpperCAmelCase_     ):
 if b < 0:
  return 1 / actual_power(UpperCAmelCase_  ,	UpperCAmelCase_     )
 return actual_power(UpperCAmelCase_  ,	UpperCAmelCase_     )


if __name__ == "__main__":
 print(power(-2, -3))




