

import math







def 						lowerCamelCase__      ( __A    :float	,__A    :float		):


       """simple docstring"""




       if initial_intensity < 0:
              raise ValueError("""The value of intensity cannot be negative"""		)
              # handling of negative values of initial intensity
       if angle < 0 or angle > 3_6_0:
              raise ValueError("""In Malus Law, the angle is in the range 0-360 degrees"""		)
              # handling of values out of allowed range
       return initial_intensity * (math.cos(math.radians(__A		)		) ** 2)


if __name__ == "__main__":
    import doctest

    doctest.testmod(name='''malus_law''')




from PIL import Image







def 						lowerCamelCase__      ( __A    :Image		):


       """simple docstring"""




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

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


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

