
"""simple docstring"""




import numpy as np
from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey

from digital_image_processing.filters.convolve import img_convolve

def __snake_case (      UpperCamelCase    )       ->    Dict:


		"""simple docstring"""





		a__   		=     np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]    )
		a__   		=     np.array([[1, 2, 1], [0, 0, 0], [-1, -2, -1]]    )

		a__   		=     np.abs(img_convolve(UpperCamelCase						,					UpperCamelCase    )    )
		a__   		=     np.abs(img_convolve(UpperCamelCase						,					UpperCamelCase    )    )
		# modify the pix within [0, 255]
		a__   		=     dst_x * 255 / np.max(UpperCamelCase    )
		a__   		=     dst_y * 255 / np.max(UpperCamelCase    )

		a__   		=     np.sqrt((np.square(UpperCamelCase    )) + (np.square(UpperCamelCase    ))    )
		a__   		=     dst_xy * 255 / np.max(UpperCamelCase    )
		a__   		=     dst_xy.astype(np.uinta    )

		a__   		=     np.arctana(UpperCamelCase						,					UpperCamelCase    )
		return dst, theta


if __name__ == "__main__":
					# read original image
					__lowerCAmelCase							:  int 				=		imread('''../image_data/lena.jpg''')
					# turn image in gray scale value
					__lowerCAmelCase							:  int 				=		cvtColor(img, COLOR_BGR2GRAY)

					__lowerCAmelCase				,__lowerCAmelCase							:  Optional[Any] 				=		sobel_filter(gray)

					# show result images
					imshow('''sobel filter''', sobel_grad)
					imshow('''sobel theta''', sobel_theta)
					waitKey(0)






"""simple docstring"""




def __snake_case (      UpperCamelCase    )       ->    float:


		"""simple docstring"""





		return -num if num < 0 else num

def __snake_case (      UpperCamelCase    )       ->    int:


		"""simple docstring"""





		if len(UpperCamelCase    ) == 0:
				raise ValueError('''abs_min() arg is an empty sequence'''    )
		a__   		=     x[0]
		for i in x:
				if abs_val(UpperCamelCase    ) < abs_val(UpperCamelCase    ):
						a__   		=     i
		return j

def __snake_case (      UpperCamelCase    )       ->    int:


		"""simple docstring"""





		if len(UpperCamelCase    ) == 0:
				raise ValueError('''abs_max() arg is an empty sequence'''    )
		a__   		=     x[0]
		for i in x:
				if abs(UpperCamelCase    ) > abs(UpperCamelCase    ):
						a__   		=     i
		return j

def __snake_case (      UpperCamelCase    )       ->    int:


		"""simple docstring"""





		if len(UpperCamelCase    ) == 0:
				raise ValueError('''abs_max_sort() arg is an empty sequence'''    )
		return sorted(UpperCamelCase						,					key=UpperCamelCase    )[-1]

def __snake_case (      )       ->    Optional[int]:


		"""simple docstring"""





		assert abs_val(0    ) == 0
		assert abs_val(34    ) == 34
		assert abs_val(-100_000_000_000    ) == 100_000_000_000

		a__   		=     [-3, -1, 2, -11]
		assert abs_max(UpperCamelCase    ) == -11
		assert abs_max_sort(UpperCamelCase    ) == -11
		assert abs_min(UpperCamelCase    ) == -1


if __name__ == "__main__":
					import doctest

					doctest.testmod()

					test_abs_val()
					print(abs_val(-34))  # --> 34




