

from cva import destroyAllWindows, imread, imshow, waitKey







def  UpperCAmelCase_   (_lowerCAmelCase :		List[Any]     ,			_lowerCAmelCase :		int		):
			__UpperCamelCase							,				__UpperCamelCase    :    Optional[Any]								=      img.shape[0], img.shape[1]

			def to_grayscale(_lowerCAmelCase :		Optional[Any]     ,			_lowerCAmelCase :		List[str]     ,			_lowerCAmelCase :		Union[str, Any]		):
						return 0.2_126 * red + 0.587 * green + 0.114 * blue

			def normalize(_lowerCAmelCase :		Optional[Any]		):
						return min(_lowerCAmelCase     ,			2_55		)

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

			return img


if __name__ == "__main__":
					# read original image
					lowercase     :       Optional[Any]        =       {
					    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()


from __future__ import annotations







def  UpperCAmelCase_   (_lowerCAmelCase :		int     ,			_lowerCAmelCase :		list[int]     ,			_lowerCAmelCase :		list[int]     ,			_lowerCAmelCase :		int		):

			# Base Case
			if counter == 0 or capacity == 0:
						return 0

			# If weight of the nth item is more than Knapsack of capacity,
			#   then this item cannot be included in the optimal solution,
			# else return the maximum of two cases:
			#   (1) nth item included
			#   (2) not included
			if weights[counter - 1] > capacity:
						return knapsack(_lowerCAmelCase     ,			_lowerCAmelCase     ,			_lowerCAmelCase     ,			counter - 1		)
			else:
						__UpperCamelCase    :    Tuple								=      capacity - weights[counter - 1]
						__UpperCamelCase    :    List[str]								=      values[counter - 1] + knapsack(
						    _lowerCAmelCase     ,			_lowerCAmelCase     ,			_lowerCAmelCase     ,			counter - 1		)
						__UpperCamelCase    :    Dict								=      knapsack(_lowerCAmelCase     ,			_lowerCAmelCase     ,			_lowerCAmelCase     ,			counter - 1		)
						return max(_lowerCAmelCase     ,			_lowerCAmelCase		)


if __name__ == "__main__":
					import doctest

					doctest.testmod()