code: 
  
  
  
  
  
  
  from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
  from numpy import array, dot, pad, ravel, uinta, zeros
  
  
  
  
  
  
  
  def 			lowercase__  (				A_:	str     ,			A_:	Optional[Any]		)  ->							Optional[int]:
  
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
         __UpperCAmelCase							,   __UpperCAmelCase    							=image.shape
         __UpperCAmelCase    							=cols - block_size[1] + 1
         __UpperCAmelCase    							=rows - block_size[0] + 1
         __UpperCAmelCase    							=zeros((dst_height * dst_width, block_size[1] * block_size[0])		)
         __UpperCAmelCase    							=0
         for i in range(0     ,			A_		):
                for j in range(0     ,			A_		):
                       __UpperCAmelCase    							=ravel(image[i : i + block_size[0], j : j + block_size[1]]		)
                       __UpperCAmelCase    							=window
                       row += 1
  
         return image_array
  
  
  
  
  
  
  
  def 			lowercase__  (				A_:	int     ,			A_:	Optional[int]		)  ->							Tuple:
  
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
         __UpperCAmelCase							,   __UpperCAmelCase    							=image.shape[0], image.shape[1]
         __UpperCAmelCase    							=filter_kernel.shape[0]
         __UpperCAmelCase    							=k_size // 2
         # Pads image with the edge values of array.
         __UpperCAmelCase    							=pad(A_     ,			A_     ,			mode="""edge"""		)
  
         # im2col, turn the k_size*k_size pixels into a row and np.vstack all rows
         __UpperCAmelCase    							=imacol(A_     ,			(k_size, k_size)		)
  
         #  turn the kernel into shape(k*k, 1)
         __UpperCAmelCase    							=ravel(A_		)
         # reshape and get the dst image
         __UpperCAmelCase    							=dot(A_     ,			A_		).reshape(A_     ,			A_		)
         return dst
  
  
  if __name__ == "__main__":
     # read original image
     __A  							=  imread(r"../image_data/lena.jpg")
     # turn image in gray scale value
     __A  							=  cvtColor(img, COLOR_BGR2GRAY)
     # Laplace operator
     __A  							=  array([[0, 1, 0], [1, -4, 1], [0, 1, 0]])
     __A  							=  img_convolve(gray, Laplace_kernel).astype(uinta)
     imshow("Laplacian", out)
     waitKey(0)
  
  
  
  
  
style_context: 
  
  
  
  
  
  
  from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
  from numpy import divide, inta, multiply, ravel, sort, zeros_like
  
  
  
  
  
  
  
  def 			lowercase__  (				A_:	int     ,			A_:	Any=3		)  ->							Dict:
  
  
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
         __UpperCAmelCase    							=int(mask / 2		)
         # copy image size
         __UpperCAmelCase    							=zeros_like(A_		)
         for i in range(A_     ,			gray_img.shape[0] - bd		):
                for j in range(A_     ,			gray_img.shape[1] - bd		):
                       # get mask according with mask
                       __UpperCAmelCase    							=ravel(gray_img[i - bd : i + bd + 1, j - bd : j + bd + 1]		)
                       # calculate mask median
                       __UpperCAmelCase    							=sort(A_		)[inta(divide((multiply(A_     ,			A_		))     ,			2		) + 1		)]
                       __UpperCAmelCase    							=median
         return median_img
  
  
  if __name__ == "__main__":
     # read original image
     __A  							=  imread("../image_data/lena.jpg")
     # turn image in gray scale value
     __A  							=  cvtColor(img, COLOR_BGR2GRAY)
  
     # get values with two different mask size
     __A  							=  median_filter(gray, 3)
     __A  							=  median_filter(gray, 5)
  
     # show result images
     imshow("median filter with 3x3 mask", medianaxa)
     imshow("median filter with 5x5 mask", medianaxa)
     waitKey(0)
  
  
  
  
  