


"""simple docstring"""



from cva import destroyAllWindows, imread, imshow, waitKey
def     UpperCAmelCase    (					_lowercase   :      Union[str, Any] ,      _lowercase   :      int  )	->   Optional[Any]:


	"""simple docstring"""




	lowerCAmelCase_       ,  lowerCAmelCase_			       = img.shape[0], img.shape[1]

	def to_grayscale(_lowercase   :      List[str] ,      _lowercase   :      Optional[Any] ,      _lowercase   :      Optional[int]  ):
		return 0.2_1_2_6 * red + 0.5_8_7 * green + 0.1_1_4 * blue

	def normalize(_lowercase   :      Optional[int]  ):
		return min(_lowercase ,      2_5_5  )

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

	return img


if __name__ == "__main__":
		# read original image
		lowercase_							 =       {
		    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()



"""simple docstring"""



def     UpperCAmelCase    (					_lowercase   :      list[int]  )	->   int:


	"""simple docstring"""




	lowerCAmelCase_			       = len(_lowercase  )
	if n in (0, 1):
		return 0
	return sum(query * (n - i - 1) for i, query in enumerate(sorted(_lowercase  )  )  )


if __name__ == "__main__":
		import doctest

		doctest.testmod()