





import copy
import os

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




class 			__UpperCamelCase    :





     def __init__(     self					):
        _UpperCAmelCase           =   ''''''
        _UpperCAmelCase           =   ''''''
        _UpperCAmelCase           =   []
        _UpperCAmelCase           =   0
        _UpperCAmelCase           =   256
        _UpperCAmelCase           =   0
        _UpperCAmelCase           =   0
        _UpperCAmelCase           =   0
        _UpperCAmelCase           =   0





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





     def 		UpperCamelCase(     self					):
        plt.hist(self.img.ravel()				,							256				,							[0, 256]					)





     def 		UpperCamelCase(     self					):
        cva.imshow('''Output-Image'''				,							self.img					)
        cva.imshow('''Input-Image'''				,							self.original_image					)
        cva.waitKey(5000					)
        cva.destroyAllWindows()


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



'''simple docstring'''







from ..utils import DummyObject, requires_backends
class 						UpperCamelCase__       (			metaclass=SCREAMING_SNAKE_CASE_						):



     """simple docstring"""






     __magic_name__           =     ["torch", "torchsde"]







     def __init__(			self   ,						*snake_case__   ,						**snake_case__ ):

            '''simple docstring'''

            requires_backends(self   ,						['torch', 'torchsde'] )







     @classmethod
     def a						(			cls   ,						*snake_case__   ,						**snake_case__ ):

            '''simple docstring'''

            requires_backends(cls   ,						['torch', 'torchsde'] )







     @classmethod
     def a						(			cls   ,						*snake_case__   ,						**snake_case__ ):

            '''simple docstring'''

            requires_backends(cls   ,						['torch', 'torchsde'] )

