





from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
from numpy import divide, inta, multiply, ravel, sort, zeros_like
def 				__UpperCamelCase  (		snake_case    ,	snake_case=3     )  ->						Union[str, Any]:


   '''simple docstring'''







   __A				 =       int(mask / 2     )
   # copy image size
   __A				 =       zeros_like(snake_case     )
   for i in range(snake_case    ,	gray_img.shape[0] - bd     ):
      for j in range(snake_case    ,	gray_img.shape[1] - bd     ):
         # get mask according with mask
         __A				 =       ravel(gray_img[i - bd : i + bd + 1, j - bd : j + bd + 1]     )
         # calculate mask median
         __A				 =       sort(snake_case     )[inta(divide((multiply(snake_case    ,	snake_case     ))    ,	2     ) + 1     )]
         __A				 =       median
   return median_img


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

    # get values with two different mask size
    _UpperCamelCase   :							Union[str, Any]     =	median_filter(gray, 3)
    _UpperCamelCase   :							Any     =	median_filter(gray, 5)

    # show result images
    imshow("""median filter with 3x3 mask""", medianaxa)
    imshow("""median filter with 5x5 mask""", medianaxa)
    waitKey(0)








import numpy as np
def 				__UpperCamelCase  (		snake_case     )  ->						Any:


   '''simple docstring'''







   __A ,						__A				 =       a.shape
   __A				 =       min(snake_case    ,	snake_case     )
   __A				 =       np.eye(snake_case     )
   __A				 =       a.copy()

   for k in range(t - 1     ):
      # select a column of modified matrix A':
      __A				 =       r[k:, [k]]
      # construct first basis vector
      __A				 =       np.zeros_like(snake_case     )
      __A				 =       1.0
      # determine scaling factor
      __A				 =       np.linalg.norm(snake_case     )
      # construct vector v for Householder reflection
      __A				 =       x + np.sign(x[0]     ) * alpha * ea
      v /= np.linalg.norm(snake_case     )

      # construct the Householder matrix
      __A				 =       np.eye(m - k     ) - 2.0 * v @ v.T
      # pad with ones and zeros as necessary
      __A				 =       np.block([[np.eye(snake_case     ), np.zeros((k, m - k)     )], [np.zeros((m - k, k)     ), q_k]]     )

      __A				 =       q @ q_k.T
      __A				 =       q_k @ r

   return q, r


if __name__ == "__main__":
    import doctest

    doctest.testmod()

