



"""simple docstring"""






import copy
import os

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

class 						__lowerCAmelCase				:


					'''simple docstring'''


					def __init__(   self ):




										"""simple docstring"""





										snake_case_    :Any										=    ''''''
										snake_case_    :Union[str, Any]										=    ''''''
										snake_case_    :Optional[Any]										=    []
										snake_case_    :Any										=    0
										snake_case_    :Dict										=    2_56
										snake_case_    :Optional[Any]										=    0
										snake_case_    :Dict										=    0
										snake_case_    :int										=    0
										snake_case_    :Dict										=    0







					def 		_a			(   self     ,							a ):




										"""simple docstring"""





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







					def 		_a			(   self ):




										"""simple docstring"""





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







					def 		_a			(   self ):




										"""simple docstring"""





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


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








"""simple docstring"""





from __future__ import annotations



def 					lowerCAmelCase_      (   SCREAMING_SNAKE_CASE							:				list[int | str] ):


							'''simple docstring'''







							create_state_space_tree(SCREAMING_SNAKE_CASE     ,    []     ,    0     ,    [0 for i in range(len(SCREAMING_SNAKE_CASE ) )] )



def 					lowerCAmelCase_      (   SCREAMING_SNAKE_CASE							:				list[int | str]     ,    SCREAMING_SNAKE_CASE							:				list[int | str]     ,    SCREAMING_SNAKE_CASE							:				int     ,    SCREAMING_SNAKE_CASE							:				list[int]     ,    ):


							'''simple docstring'''







							if index == len(SCREAMING_SNAKE_CASE ):
														print(SCREAMING_SNAKE_CASE )
														return

							for i in range(len(SCREAMING_SNAKE_CASE ) ):
														if not index_used[i]:
																					current_sequence.append(sequence[i] )
																					__lowerCamelCase   :   List[Any]       =True
																					create_state_space_tree(SCREAMING_SNAKE_CASE     ,    SCREAMING_SNAKE_CASE     ,    index + 1     ,    SCREAMING_SNAKE_CASE )
																					current_sequence.pop()
																					__lowerCamelCase   :   List[Any]       =False
_UpperCamelCase					      =   [3, 1, 2, 4]
generate_all_permutations(sequence)

_UpperCamelCase					      =   ["A", "B", "C"]
generate_all_permutations(sequence_a)




