





"""simple docstring"""






# Lint as: python3
import dataclasses
import re
from dataclasses import dataclass
from functools import total_ordering
from typing import Optional, Union


A	     =					re.compile(r'''^(?P<major>\d+)''' r'''\.(?P<minor>\d+)''' r'''\.(?P<patch>\d+)$''')




@total_ordering
@dataclass
class 			__lowercase     :







					'''simple docstring'''




					__lowerCAmelCase					=					42
					__lowerCAmelCase					=					None
					__lowerCAmelCase					=					None
					__lowerCAmelCase					=					None
					__lowerCAmelCase					=					None







					def 	_lowerCamelCase						(  self       ):
									__a    ,  __a    ,  __a	:  Optional[int]         =					_str_to_version_tuple(self.version_str       )







					def __repr__(  self       ):
									return f"""{self.tuple[0]}.{self.tuple[1]}.{self.tuple[2]}"""







					@property
					def 	_lowerCamelCase						(  self       ):
									return self.major, self.minor, self.patch







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase       ):
									if isinstance(_UpperCAmelCase		,     _UpperCAmelCase       ):
													return Version(_UpperCAmelCase       )
									elif isinstance(_UpperCAmelCase		,     _UpperCAmelCase       ):
													return other
									raise TypeError(f"""{other} (type {type(_UpperCAmelCase       )}) cannot be compared to version."""       )







					def __eq__(  self		,     _UpperCAmelCase       ):
									try:
													__a	:  List[str]         =					self._validate_operand(_UpperCAmelCase       )
									except (TypeError, ValueError):
													return False
									else:
													return self.tuple == other.tuple







					def __lt__(  self		,     _UpperCAmelCase       ):
									__a	:  Optional[Any]         =					self._validate_operand(_UpperCAmelCase       )
									return self.tuple < other.tuple







					def __hash__(  self       ):
									return hash(_version_tuple_to_str(self.tuple       )       )







					@classmethod
					def 	_lowerCamelCase						(  cls		,     _UpperCAmelCase       ):
									__a	:  Dict         =					{f.name for f in dataclasses.fields(cls       )}
									return cls(**{k: v for k, v in dic.items() if k in field_names}       )







					def 	_lowerCamelCase						(  self       ):
									return self.version_str






def       __A (     a_  :Optional[int])						->						Tuple:
				__a	:  Any         =					_VERSION_REG.match(a_)
				if not res:
								raise ValueError(F"""Invalid version '{version_str}'. Format should be x.y.z with {{x,y,z}} being digits.""")
				return tuple(int(a_) for v in [res.group('''major'''), res.group('''minor'''), res.group('''patch''')])






def       __A (     a_  :Optional[int])						->						List[Any]:
				return ".".join(str(a_) for v in version_tuple)






"""simple docstring"""






from pathlib import Path

import numpy as np
from PIL import Image

def       __A (     a_  :np.ndarray)						->						np.ndarray:
				__a    ,  __a    ,  __a	:  Union[str, Any]         =					rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2]
				return 0.2_9_8_9 * r + 0.5_8_7_0 * g + 0.1_1_4_0 * b

def       __A (     a_  :np.ndarray)						->						np.ndarray:
				return (gray > 1_27) & (gray <= 2_55)

def       __A (     a_  :np.ndarray				,    a_  :np.ndarray)						->						np.ndarray:
				__a	:  Optional[int]         =					np.zeros_like(a_)
				__a	:  Dict         =					np.zeros(
				    (image.shape[0] + kernel.shape[0] - 1, image.shape[1] + kernel.shape[1] - 1))

				# Copy image to padded image
				__a	:  int         =					image

				# Iterate over image & apply kernel
				for x in range(image.shape[1]):
								for y in range(image.shape[0]):
												__a	:  Optional[Any]         =					(
												    kernel * image_padded[y : y + kernel.shape[0], x : x + kernel.shape[1]]
												).sum()
												__a	:  Any         =					int(summation > 0)
				return output


if __name__ == "__main__":
		# read original image
		A	     =					Path(__file__).resolve().parent / '''image_data''' / '''lena.jpg'''
		A	     =					np.array(Image.open(lena_path))
		# kernel to be applied
		A	     =					np.array([[0, 1, 0], [1, 1, 1], [0, 1, 0]])
		A	     =					dilation(gray_to_binary(rgb_to_gray(lena)), structuring_element)
		# Save the output image
		A	     =					Image.fromarray(output).convert('''RGB''')
		pil_img.save('''result_dilation.png''')