






"""simple docstring"""
import numpy as np
from cva import destroyAllWindows, imread, imshow, waitKey


class _lowerCAmelCase						:







						def __init__(    self   ,				lowerCAmelCase_   ,				lowerCAmelCase_   ,				lowerCAmelCase_							)		->							List[str]:
										if dst_width < 0 or dst_height < 0:
														raise ValueError('Destination width/height should be > 0'							)

										_SCREAMING_SNAKE_CASE   :		int       		=    img
										_SCREAMING_SNAKE_CASE   :		str       		=    img.shape[1]
										_SCREAMING_SNAKE_CASE   :		Optional[int]       		=    img.shape[0]
										_SCREAMING_SNAKE_CASE   :		List[str]       		=    dst_width
										_SCREAMING_SNAKE_CASE   :		Tuple       		=    dst_height

										_SCREAMING_SNAKE_CASE   :		Optional[Any]       		=    self.src_w / self.dst_w
										_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    self.src_h / self.dst_h

										_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    (
										    np.ones((self.dst_h, self.dst_w, 3)   ,				np.uinta							) * 2_5_5
										)







						def 			A      (    self							)		->							List[Any]:
										for i in range(self.dst_h							):
														for j in range(self.dst_w							):
																		_SCREAMING_SNAKE_CASE   :		str       		=    self.img[self.get_y(lowerCAmelCase_							)][self.get_x(lowerCAmelCase_							)]







						def 			A      (    self   ,				lowerCAmelCase_							)		->							int:
										return int(self.ratio_x * x							)







						def 			A      (    self   ,				lowerCAmelCase_							)		->							int:
										return int(self.ratio_y * y							)


if __name__ == "__main__":
			lowerCAmelCase__						, lowerCAmelCase__    						=			800, 600
			lowerCAmelCase__    						=			imread('image_data/lena.jpg', 1)
			lowerCAmelCase__    						=			NearestNeighbour(im, dst_w, dst_h)
			n.process()

			imshow(
			    F'Image resized from: {im.shape[1]}x{im.shape[0]} to {dst_w}x{dst_h}', n.output
			)
			waitKey(0)
			destroyAllWindows()









"""simple docstring"""
class _lowerCAmelCase						:







						def __init__(    self   ,				lowerCAmelCase_							)		->							None:
										_SCREAMING_SNAKE_CASE   :		Dict       		=    size
										_SCREAMING_SNAKE_CASE   :		str       		=    [0] * size
										_SCREAMING_SNAKE_CASE   :		Any       		=    [0] * size







						@staticmethod
						def 			A      (    lowerCAmelCase_							)		->							int:
										return index | (index + 1)







						@staticmethod
						def 			A      (    lowerCAmelCase_							)		->							int:
										return (index & (index + 1)) - 1







						def 			A      (    self   ,				lowerCAmelCase_   ,				lowerCAmelCase_							)		->							None:
										_SCREAMING_SNAKE_CASE   :		str       		=    value
										while index < self.size:
														_SCREAMING_SNAKE_CASE   :		List[str]       		=    self.get_prev(lowerCAmelCase_							) + 1
														if current_left_border == index:
																		_SCREAMING_SNAKE_CASE   :		List[str]       		=    value
														else:
																		_SCREAMING_SNAKE_CASE   :		Optional[Any]       		=    max(lowerCAmelCase_   ,				lowerCAmelCase_   ,				lowerCAmelCase_							)
														_SCREAMING_SNAKE_CASE   :		str       		=    self.get_next(lowerCAmelCase_							)







						def 			A      (    self   ,				lowerCAmelCase_   ,				lowerCAmelCase_							)		->							int:
										right -= 1  # Because of right is exclusive
										_SCREAMING_SNAKE_CASE   :		List[Any]       		=    0
										while left <= right:
														_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    self.get_prev(lowerCAmelCase_							)
														if left <= current_left:
																		_SCREAMING_SNAKE_CASE   :		Union[str, Any]       		=    max(lowerCAmelCase_   ,				self.tree[right]							)
																		_SCREAMING_SNAKE_CASE   :		List[Any]       		=    current_left
														else:
																		_SCREAMING_SNAKE_CASE   :		List[str]       		=    max(lowerCAmelCase_   ,				self.arr[right]							)
																		right -= 1
										return result


if __name__ == "__main__":
			import doctest

			doctest.testmod()

