- medianBlur
OpenCV Median blur
- The kernel here is always square (for whatever reason) and thus we only pass a single number
- Usually used with small kernel sizes (less than 7)
examples/opencv/median_blur.py
import cv2 as cv import sys if len(sys.argv) != 3: exit(f"Usage: {sys.argv[0]} FILENAME KERNEL") filename = sys.argv[1] kernel = int(sys.argv[2]) original = cv.imread(filename) cv.imshow('Original', original) blurred = cv.medianBlur(original, ksize=kernel) cv.imshow('Median Blurred', blurred) cv.waitKey(0)