
'''simple docstring'''



UpperCamelCase__ :						Tuple    							=					1_000
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_  )       ->       float:




   """simple docstring"""
   return x * x
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_ = 4  )       ->       float:




   """simple docstring"""
   assert callable(
       SCREAMING_SNAKE_CASE_  ), F"the function(object) passed should be callable your input : {function}"
   assert isinstance(SCREAMING_SNAKE_CASE_      , (float, int)  ), F"a should be float or integer your input : {a}"
   assert isinstance(function(SCREAMING_SNAKE_CASE_  )      , (float, int)  ), (
       "the function should return integer or float return type of your function, "
       F"{type(SCREAMING_SNAKE_CASE_  )}"
   )
   assert isinstance(SCREAMING_SNAKE_CASE_      , (float, int)  ), F"b should be float or integer your input : {b}"
   assert (
       isinstance(SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_  ) and precision > 0
   ), F"precision should be positive integer your input : {precision}"

   # just applying the formula of simpson for approximate integration written in
   # mentioned article in first comment of this file and above this function

   _SCREAMING_SNAKE_CASE       	=			(b - a) / N_STEPS
   _SCREAMING_SNAKE_CASE       	=			function(SCREAMING_SNAKE_CASE_  ) + function(SCREAMING_SNAKE_CASE_  )

   for i in range(1      , SCREAMING_SNAKE_CASE_  ):
      _SCREAMING_SNAKE_CASE       	=			a + h * i
      result += function(SCREAMING_SNAKE_CASE_  ) * (4 if i % 2 else 2)

   result *= h / 3
   return round(SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_  )


if __name__ == "__main__":
     import doctest

     doctest.testmod()








'''simple docstring'''



from cva import destroyAllWindows, imread, imshow, waitKey
def 				lowerCAmelCase_		(			SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_  )       ->       Dict:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE	,							_SCREAMING_SNAKE_CASE       	=			img.shape[0], img.shape[1]

   def to_grayscale(SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_  ):
      return 0.2126 * red + 0.587 * green + 0.114 * blue

   def normalize(SCREAMING_SNAKE_CASE_  ):
      return min(SCREAMING_SNAKE_CASE_      , 2_55  )

   for i in range(SCREAMING_SNAKE_CASE_  ):
      for j in range(SCREAMING_SNAKE_CASE_  ):
         _SCREAMING_SNAKE_CASE       	=			int(to_grayscale(*img[i][j]  )  )
         _SCREAMING_SNAKE_CASE       	=			[
             normalize(SCREAMING_SNAKE_CASE_  ),
             normalize(greyscale + factor  ),
             normalize(greyscale + 2 * factor  ),
         ]

   return img


if __name__ == "__main__":
     # read original image
     UpperCamelCase__ :						Optional[int]    							=					{
         percentage: imread("image_data/lena.jpg", 1) for percentage in (10, 20, 30, 40)
     }

     for percentage, img in images.items():
          make_sepia(img, percentage)

     for percentage, img in images.items():
          imshow(f"""Original image with sepia (factor: {percentage})""", img)

     waitKey(0)
     destroyAllWindows()






