



'''simple docstring'''




import copy
import os

import cva
import numpy as np
from matplotlib import pyplot as plt






class 		_UpperCamelCase						:

			def __init__(							self  :				Optional[int]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Any					 =	""""""
					__SCREAMING_SNAKE_CASE :	int					 =	""""""
					__SCREAMING_SNAKE_CASE :	Dict					 =	[]
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	0
					__SCREAMING_SNAKE_CASE :	Dict					 =	2_5_6
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	0
					__SCREAMING_SNAKE_CASE :	List[str]					 =	0
					__SCREAMING_SNAKE_CASE :	Union[str, Any]					 =	0
					__SCREAMING_SNAKE_CASE :	List[str]					 =	0

			def UpperCamelCase__      (							self  :				List[str]							,  lowerCAmelCase__  :				Tuple		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	cva.imread(lowerCAmelCase__							,  0		)
					__SCREAMING_SNAKE_CASE :	int					 =	copy.deepcopy(self.img		)
					__SCREAMING_SNAKE_CASE :	str					 =	plt.hist(self.img.ravel()							,  2_5_6							,  [0, 2_5_6]							,  label="""x"""		)
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	np.sum(lowerCAmelCase__		)
					for i in range(len(lowerCAmelCase__		)		):
							__SCREAMING_SNAKE_CASE :	Tuple					 =	x[i] / self.k
							self.sk += prk
							__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	(self.L - 1) * self.sk
							if self.rem != 0:
									__SCREAMING_SNAKE_CASE :	int					 =	int(last % last		)
							__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	int(last + 1 if self.rem >= 0.5 else last		)
							self.last_list.append(lowerCAmelCase__		)
							__SCREAMING_SNAKE_CASE :	str					 =	int(np.ma.count(self.img		) / self.img[1].size		)
							__SCREAMING_SNAKE_CASE :	Any					 =	self.img[1].size
					for i in range(self.number_of_cols		):
							for j in range(self.number_of_rows		):
									__SCREAMING_SNAKE_CASE :	List[str]					 =	self.img[j][i]
									if num != self.last_list[num]:
											__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	self.last_list[num]
					cva.imwrite("""output_data/output.jpg"""							,  self.img		)

			def UpperCamelCase__      (							self  :				Dict		):





					"""simple docstring"""






					plt.hist(self.img.ravel()							,  2_5_6							,  [0, 2_5_6]		)



			def UpperCamelCase__      (							self  :				Dict		):





					"""simple docstring"""






					cva.imshow("""Output-Image"""							,  self.img		)
					cva.imshow("""Input-Image"""							,  self.original_image		)
					cva.waitKey(5_0_0_0		)
					cva.destroyAllWindows()


if __name__ == "__main__":
						UpperCamelCase__ :			Union[str, Any]												=				os.path.join(os.path.basename(__file__), '''image_data/input.jpg''')
						UpperCamelCase__ :			Any												=				ConstantStretch()
						stretcher.stretch(file_path)
						stretcher.plot_histogram()
						stretcher.show_image()




'''simple docstring'''




def        lowerCAmelCase_     (			_lowerCamelCase:     int      ):
		if number > 0:
				raise ValueError("""input must be a negative integer"""      )
		__SCREAMING_SNAKE_CASE :	str					 =	len(bin(_lowerCamelCase      )[3:]      )
		__SCREAMING_SNAKE_CASE :	Any					 =	bin(abs(_lowerCamelCase      ) - (1 << binary_number_length)      )[3:]
		__SCREAMING_SNAKE_CASE :	Optional[int]					 =	(
		    (
		        """1"""
		        + """0""" * (binary_number_length - len(_lowerCamelCase      ))
		        + twos_complement_number
		    )
		    if number < 0
		    else """0"""
		)
		return "0b" + twos_complement_number


if __name__ == "__main__":
						import doctest

						doctest.testmod()