


"""simple docstring"""






from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
from numpy import array, dot, pad, ravel, uinta, zeros


def __lowercase  (   lowerCamelCase_	:   Tuple    ,       lowerCamelCase_	:   Tuple	):
				SCREAMING_SNAKE_CASE__				,   SCREAMING_SNAKE_CASE__  				=					image.shape
				SCREAMING_SNAKE_CASE__  				=					cols - block_size[1] + 1
				SCREAMING_SNAKE_CASE__  				=					rows - block_size[0] + 1
				SCREAMING_SNAKE_CASE__  				=					zeros((dst_height * dst_width, block_size[1] * block_size[0])	)
				SCREAMING_SNAKE_CASE__  				=					0
				for i in range(0    ,       lowerCamelCase_	):
								for j in range(0    ,       lowerCamelCase_	):
												SCREAMING_SNAKE_CASE__  				=					ravel(image[i : i + block_size[0], j : j + block_size[1]]	)
												SCREAMING_SNAKE_CASE__  				=					window
												row += 1

				return image_array


def __lowercase  (   lowerCamelCase_	:   Optional[int]    ,       lowerCamelCase_	:   Any	):
				SCREAMING_SNAKE_CASE__				,   SCREAMING_SNAKE_CASE__  				=					image.shape[0], image.shape[1]
				SCREAMING_SNAKE_CASE__  				=					filter_kernel.shape[0]
				SCREAMING_SNAKE_CASE__  				=					k_size // 2
				# Pads image with the edge values of array.
				SCREAMING_SNAKE_CASE__  				=					pad(lowerCamelCase_    ,       lowerCamelCase_    ,       mode="edge"	)

				# im2col, turn the k_size*k_size pixels into a row and np.vstack all rows
				SCREAMING_SNAKE_CASE__  				=					imacol(lowerCamelCase_    ,       (k_size, k_size)	)

				#  turn the kernel into shape(k*k, 1)
				SCREAMING_SNAKE_CASE__  				=					ravel(lowerCamelCase_	)
				# reshape and get the dst image
				SCREAMING_SNAKE_CASE__  				=					dot(lowerCamelCase_    ,       lowerCamelCase_	).reshape(lowerCamelCase_    ,       lowerCamelCase_	)
				return dst


if __name__ == "__main__":
	# read original image
	_lowerCamelCase  =	imread(R'../image_data/lena.jpg')
	# turn image in gray scale value
	_lowerCamelCase  =	cvtColor(img, COLOR_BGR2GRAY)
	# Laplace operator
	_lowerCamelCase  =	array([[0, 1, 0], [1, -4, 1], [0, 1, 0]])
	_lowerCamelCase  =	img_convolve(gray, Laplace_kernel).astype(uinta)
	imshow('Laplacian', out)
	waitKey(0)




"""simple docstring"""






from __future__ import annotations

from collections.abc import Generator


def __lowercase  (   lowerCamelCase_	:   int	):
				if not isinstance(lowerCamelCase_    ,       lowerCamelCase_	) or n < 1:
								raise Exception("Sequence only defined for positive integers"	)

				yield n
				while n != 1:
								if n % 2 == 0:
												n //= 2
								else:
												SCREAMING_SNAKE_CASE__  				=					3 * n + 1
								yield n


def __lowercase  (   ):
				SCREAMING_SNAKE_CASE__  				=					43
				SCREAMING_SNAKE_CASE__  				=					tuple(collatz_sequence(lowerCamelCase_	)	)
				print(lowerCamelCase_	)
				print(F'''Collatz sequence from {n} took {len(lowerCamelCase_	)} steps.'''	)


if __name__ == "__main__":
	main()
