code: def median_fltr_opencv(dem, size=3, iterations=1):
      
      import cv2
      dem = malib.checkma(dem)
      if size > 5:
          print("Need to implement iteration")
      n = 0
      out = dem
      while n <= iterations:
          dem_cv = cv2.medianBlur(out.astype(np.float32).filled(np.nan), size)
          out = np.ma.fix_invalid(dem_cv)
          out.set_fill_value(dem.fill_value)
          n += 1
      return out
docs: OpenCV median filter