




def 						lowercase		(     _lowerCAmelCase      ):
  UpperCAmelCase__    						=   str(_lowerCAmelCase      ).strip()
  if not oct_string:
    raise ValueError("""Empty string was passed to the function"""      )
  UpperCAmelCase__    						=   oct_string[0] == """-"""
  if is_negative:
    UpperCAmelCase__    						=   oct_string[1:]
  if not oct_string.isdigit() or not all(0 <= int(_lowerCAmelCase      ) <= 7 for char in oct_string      ):
    raise ValueError("""Non-octal value was passed to the function"""      )
  UpperCAmelCase__    						=   0
  for char in oct_string:
    UpperCAmelCase__    						=   8 * decimal_number + int(_lowerCAmelCase      )
  if is_negative:
    UpperCAmelCase__    						=   -decimal_number
  return decimal_number


if __name__ == "__main__":
   from doctest import testmod

   testmod()










from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
from numpy import divide, inta, multiply, ravel, sort, zeros_like


def 						lowercase		(     _lowerCAmelCase   ,     _lowerCAmelCase=3      ):
  UpperCAmelCase__    						=   int(mask / 2      )
  # copy image size
  UpperCAmelCase__    						=   zeros_like(_lowerCAmelCase      )
  for i in range(_lowerCAmelCase   ,     gray_img.shape[0] - bd      ):
    for j in range(_lowerCAmelCase   ,     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(_lowerCAmelCase      )[inta(divide((multiply(_lowerCAmelCase   ,     _lowerCAmelCase      ))   ,     2      ) + 1      )]
      UpperCAmelCase__    						=   median
  return median_img


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

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

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




