






"""simple docstring"""



import copy
import os

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



class 					a						:



    """simple docstring"""



    def __init__(     self: int       ):






         """simple docstring"""


         A__										=  ''''''
         A__										=  ''''''
         A__										=  []
         A__										=  0
         A__										=  2_56
         A__										=  0
         A__										=  0
         A__										=  0
         A__										=  0

    def 				UpperCamelCase	(     self: Optional[int]    ,						UpperCamelCase: str       ):






         """simple docstring"""


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

    def 				UpperCamelCase	(     self: int       ):






         """simple docstring"""


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





    def 				UpperCamelCase	(     self: str       ):






         """simple docstring"""


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


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









"""simple docstring"""



from collections.abc import Callable





def  _snake_case     (    UpperCAmelCase_  :					Callable[[float], float]					,   UpperCAmelCase_  :					float					,   UpperCAmelCase_  :					float			):
     A__										=  a
     A__										=  b
     if function(UpperCAmelCase_			) == 0:  # one of the a or b is a root for the function
          return a
     elif function(UpperCAmelCase_			) == 0:
          return b
     elif (
         function(UpperCAmelCase_			) * function(UpperCAmelCase_			) > 0
     ):  # if none of these are root and they are both positive or negative,
          # then this algorithm can't find the root
          raise ValueError("""could not find root in given interval."""			)
     else:
          A__										=  start + (end - start) / 2.0
          while abs(start - mid			) > 10**-7:  # until precisely equals to 10^-7
               if function(UpperCAmelCase_			) == 0:
                    return mid
               elif function(UpperCAmelCase_			) * function(UpperCAmelCase_			) < 0:
                    A__										=  mid
               else:
                    A__										=  mid
               A__										=  start + (end - start) / 2.0
          return mid





def  _snake_case     (    UpperCAmelCase_  :					float			):
     return x**3 - 2 * x - 5


if __name__ == "__main__":
 print(bisection(f, 1, 1_0_0_0))

 import doctest

 doctest.testmod()






