





'''simple docstring'''






import copy
import os

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


class   _lowercase						:


   def __init__( self					):
       A       :       Optional[Any]							=						''''''
       A       :       List[Any]							=						''''''
       A       :       Union[str, Any]							=						[]
       A       :       int							=						0
       A       :       List[Any]							=						256
       A       :       int							=						0
       A       :       Optional[int]							=						0
       A       :       int							=						0
       A       :       List[str]							=						0


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


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


   def 					snake_case				( self					):
       cva.imshow('''Output-Image'''    ,   self.img					)
       cva.imshow('''Input-Image'''    ,   self.original_image					)
       cva.waitKey(5_000					)
       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 							_lowerCamelCase(  UpperCamelCase__    : Union[str, Any]    ,       UpperCamelCase__    : str		)		->  Optional[Any]:
    A       :       Tuple							=						0
    while b > 0:
        if b & 1:
            res += a

        a += a
        b >>= 1

    return res
def 							_lowerCamelCase(  UpperCamelCase__    : Any    ,       UpperCamelCase__    : Any    ,       UpperCamelCase__    : List[str]		)		->  Any:
    A       :       str							=						0
    while b > 0:
        if b & 1:
            A       :       List[Any]							=						((res % c) + (a % c)) % c

        a += a
        b >>= 1

    return res
