




"""simple docstring"""






import numpy as np

lowercase__  		=		[
    ["""a""", """b""", """c""", """d""", """e"""],
    ["""f""", """g""", """h""", """i""", """k"""],
    ["""l""", """m""", """n""", """o""", """p"""],
    ["""q""", """r""", """s""", """t""", """u"""],
    ["""v""", """w""", """x""", """y""", """z"""],
]






class lowerCAmelCase__			:






			'''simple docstring'''



			def __init__(						self						):
							_lowerCamelCase  :    Tuple					=					np.array(lowercase						)
			def       A_					(						self						,   lowercase						):
							_lowerCamelCase,				_lowerCamelCase  :    Optional[int]					=					np.where(letter == self.SQUARE						)
							_lowerCamelCase  :    Optional[int]					=					np.concatenate([indexa + 1, indexa + 1]						)
							return indexes
			def       A_					(						self						,   lowercase						,   lowercase						):
							_lowerCamelCase  :    Any					=					self.SQUARE[indexa - 1, indexa - 1]
							return letter
			def       A_					(						self						,   lowercase						):
							_lowerCamelCase  :    Optional[int]					=					message.lower()
							_lowerCamelCase  :    str					=					message.replace(' '						,   ''						)
							_lowerCamelCase  :    Tuple					=					message.replace('j'						,   'i'						)

							_lowerCamelCase  :    Any					=					np.empty((2, len(lowercase						))						)
							for letter_index in range(len(lowercase						)						):
											_lowerCamelCase  :    int					=					self.letter_to_numbers(message[letter_index]						)

											_lowerCamelCase  :    Any					=					numbers[0]
											_lowerCamelCase  :    Optional[Any]					=					numbers[1]

							_lowerCamelCase  :    List[str]					=					first_step.reshape(2 * len(lowercase						)						)
							_lowerCamelCase  :    Any					=					''
							for numbers_index in range(len(lowercase						)						):
											_lowerCamelCase  :    int					=					int(second_step[numbers_index * 2]						)
											_lowerCamelCase  :    List[str]					=					int(second_step[(numbers_index * 2) + 1]						)
											_lowerCamelCase  :    Optional[Any]					=					self.numbers_to_letter(lowercase						,   lowercase						)
											_lowerCamelCase  :    List[Any]					=					encoded_message + letter

							return encoded_message






			def       A_					(						self						,   lowercase						):
							_lowerCamelCase  :    Tuple					=					message.lower()
							message.replace(' '						,   ''						)
							_lowerCamelCase  :    Any					=					np.empty(2 * len(lowercase						)						)
							for letter_index in range(len(lowercase						)						):
											_lowerCamelCase  :    Any					=					self.letter_to_numbers(message[letter_index]						)
											_lowerCamelCase  :    Dict					=					numbers[0]
											_lowerCamelCase  :    int					=					numbers[1]

							_lowerCamelCase  :    List[Any]					=					first_step.reshape((2, len(lowercase						))						)
							_lowerCamelCase  :    Optional[Any]					=					''
							for numbers_index in range(len(lowercase						)						):
											_lowerCamelCase  :    Dict					=					int(second_step[0, numbers_index]						)
											_lowerCamelCase  :    Any					=					int(second_step[1, numbers_index]						)
											_lowerCamelCase  :    Any					=					self.numbers_to_letter(lowercase						,   lowercase						)
											_lowerCamelCase  :    Optional[int]					=					decoded_message + letter

							return decoded_message





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






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


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