






from PIL import Image



def  a__ (__lowercase							:Image   )		-> Image:
				_A  ,				_A	:				List[Any]   =      image.size
				_A	:				Optional[int]   =      0
				_A	:				Dict   =      image.load()
				for i in range(__lowercase   ):
								for j in range(__lowercase   ):
												_A	:				Any   =      pixels[j, i]
												mean += pixel
				mean //= width * height

				for j in range(__lowercase   ):
								for i in range(__lowercase   ):
												_A	:				List[str]   =      255 if pixels[i, j] > mean else 0
				return image


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











from collections import defaultdict



def  a__ (__lowercase							:str					,  __lowercase							:str   )		-> bool:
				_A	:				Union[str, Any]   =      first_str.lower().strip()
				_A	:				int   =      second_str.lower().strip()

				# Remove whitespace
				_A	:				int   =      first_str.replace(''' '''					,  ''''''   )
				_A	:				Optional[Any]   =      second_str.replace(''' '''					,  ''''''   )

				# Strings of different lengths are not anagrams
				if len(__lowercase   ) != len(__lowercase   ):
								return False

				# Default values for count should be 0
				_A	:				defaultdict[str, int]   =      defaultdict(__lowercase   )

				# For each character in input strings,
				# increment count in the corresponding
				for i in range(len(__lowercase   )   ):
								count[first_str[i]] += 1
								count[second_str[i]] -= 1

				return all(_count == 0 for _count in count.values()   )


if __name__ == "__main__":
	from doctest import testmod

	testmod()
	_UpperCamelCase			:	Dict								=input('Enter the first string ').strip()
	_UpperCamelCase			:	Union[str, Any]								=input('Enter the second string ').strip()

	_UpperCamelCase			:	Dict								=check_anagrams(input_a, input_b)
	print(f'''{input_a} and {input_b} are {"" if status else "not "}anagrams.''')



