

'''simple docstring'''





def 				_UpperCAmelCase							(	a__     ,  a__ = 1_0_0_0):

			'''simple docstring'''



			if (not isinstance(__snake_case     ,  __snake_case)) or (digit_position <= 0):
						raise ValueError("""Digit position must be a positive integer""")
			elif (not isinstance(__snake_case     ,  __snake_case)) or (precision < 0):
						raise ValueError("""Precision must be a nonnegative integer""")

			# compute an approximation of (16 ** (n - 1)) * pi whose fractional part is mostly
			# accurate
			a_	:	int          =   (
			    4 * _subsum(__snake_case     ,  1     ,  __snake_case)
			    - 2 * _subsum(__snake_case     ,  4     ,  __snake_case)
			    - _subsum(__snake_case     ,  5     ,  __snake_case)
			    - _subsum(__snake_case     ,  6     ,  __snake_case)
			)

			# return the first hex digit of the fractional part of the result
			return hex(int((sum_result % 1) * 1_6))[2:]


def 				_UpperCAmelCase							(	a__     ,  a__     ,  a__):

			'''simple docstring'''



			a_	:	List[Any]          =   0.0
			for sum_index in range(digit_pos_to_extract + precision):
						a_	:	Optional[Any]          =   8 * sum_index + denominator_addend
						if sum_index < digit_pos_to_extract:
									# if the exponential term is an integer and we mod it by the denominator
									# before dividing, only the integer part of the sum will change;
									# the fractional part will not
									a_	:	Dict          =   pow(
									    1_6     ,  digit_pos_to_extract - 1 - sum_index     ,  __snake_case)
						else:
									a_	:	List[str]          =   pow(1_6     ,  digit_pos_to_extract - 1 - sum_index)
						total += exponential_term / denominator
			return total


if __name__ == "__main__":
	import doctest

	doctest.testmod()





from cva import destroyAllWindows, imread, imshow, waitKey


def 				_UpperCAmelCase							(	a__     ,  a__):

			'''simple docstring'''



			a_       ,				a_	:	Optional[int]          =   img.shape[0], img.shape[1]

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

			def normalize(a__):
						return min(a__     ,  2_5_5)

			for i in range(a__):
						for j in range(a__):
									a_	:	Optional[Any]          =   int(to_grayscale(*img[i][j]))
									a_	:	Union[str, Any]          =   [
									    normalize(a__),
									    normalize(greyscale + factor),
									    normalize(greyscale + 2 * factor),
									]

			return img


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


