






import copy
import os

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







class 			UpperCAmelCase_						:



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




      def     UpperCAmelCase						(				self )				->      Union[str, Any]:
          cva.imshow('''Output-Image'''    ,				self.img )
          cva.imshow('''Input-Image'''    ,				self.original_image )
          cva.waitKey(5000 )
          cva.destroyAllWindows()


if __name__ == "__main__":
 __snake_case												=  os.path.join(os.path.basename(__file__), """image_data/input.jpg""")
 __snake_case												=  ConstantStretch()
 stretcher.stretch(file_path)
 stretcher.plot_histogram()
 stretcher.show_image()










"""simple docstring"""







def 				UpperCamelCase_    (    lowerCAmelCase__      :				int = 100						)						->   int:

  """simple docstring"""




  lowerCAmelCase_   :				Any								= (n * (n + 1) // 2) ** 2
  lowerCAmelCase_   :				Optional[int]								= n * (n + 1) * (2 * n + 1) // 6
  return sum_cubes - sum_squares


if __name__ == "__main__":
     print(f'{solution() = }')





