"""simple docstring"""




import numpy as np
from cva import destroyAllWindows, imread, imshow, waitKey

class       a_      :




					def __init__(	self						:     Any  ,						snake_case__						:     Dict  ,						snake_case__						:     str  ,						snake_case__						:     Optional[Any]     ):
							if dst_width < 0 or dst_height < 0:
									raise ValueError("""Destination width/height should be > 0"""     )

							lowerCAmelCase__        =   img
							lowerCAmelCase__        =   img.shape[1]
							lowerCAmelCase__        =   img.shape[0]
							lowerCAmelCase__        =   dst_width
							lowerCAmelCase__        =   dst_height

							lowerCAmelCase__        =   self.src_w / self.dst_w
							lowerCAmelCase__        =   self.src_h / self.dst_h

							lowerCAmelCase__        =   lowerCAmelCase__        =   (
							    np.ones((self.dst_h, self.dst_w, 3)  ,						np.uinta     ) * 255
							)




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Union[str, Any]     ):
							for i in range(self.dst_h     ):
									for j in range(self.dst_w     ):
											lowerCAmelCase__        =   self.img[self.get_y(snake_case__     )][self.get_x(snake_case__     )]




					def 						_SCREAMING_SNAKE_CASE						(	self						:     List[Any]  ,						snake_case__						:     Union[str, Any]     ):
							return int(self.ratio_x * x     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Dict  ,						snake_case__						:     Tuple     ):
							return int(self.ratio_y * y     )


if __name__ == "__main__":
			__lowerCAmelCase							,	__lowerCAmelCase    :							str													=						8_00, 6_00
			__lowerCAmelCase    :							Optional[int]													=						imread("image_data/lena.jpg", 1)
			__lowerCAmelCase    :							Union[str, Any]													=						NearestNeighbour(im, dst_w, dst_h)
			n.process()

			imshow(
			    F"Image resized from: {im.shape[1]}x{im.shape[0]} to {dst_w}x{dst_h}", n.output
			)
			waitKey(0)
			destroyAllWindows()






"""simple docstring"""




import copy
import os

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

class       a_      :




					def __init__(	self						:     Optional[int]     ):
							lowerCAmelCase__        =   """"""
							lowerCAmelCase__        =   """"""
							lowerCAmelCase__        =   []
							lowerCAmelCase__        =   0
							lowerCAmelCase__        =   256
							lowerCAmelCase__        =   0
							lowerCAmelCase__        =   0
							lowerCAmelCase__        =   0
							lowerCAmelCase__        =   0




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




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Optional[Any]     ):
							plt.hist(self.img.ravel()  ,						256  ,						[0, 256]     )




					def 						_SCREAMING_SNAKE_CASE						(	self						:     Optional[Any]     ):
							cva.imshow("""Output-Image"""  ,						self.img     )
							cva.imshow("""Input-Image"""  ,						self.original_image     )
							cva.waitKey(5000     )
							cva.destroyAllWindows()


if __name__ == "__main__":
			__lowerCAmelCase    :							Dict													=						os.path.join(os.path.basename(__file__), "image_data/input.jpg")
			__lowerCAmelCase    :							Optional[int]													=						ConstantStretch()
			stretcher.stretch(file_path)
			stretcher.plot_histogram()
			stretcher.show_image()




